telepat-io/telepat-api

View on GitHub
bin/stop.sh

Summary

Maintainability
Test Coverage
#!/usr/bin/env bash

function command_exists() {
    hash "$1" &> /dev/null
}

api_id=""

while [ $# -gt 0 ]; do
    case "$1" in
        --id=*)
            api_id="${1#*=}"
        ;;
    esac
    shift
done

if command_exists "forever" ; then
    if [ $api_id ]; then
        forever stop api${api_id}
    else
        forever stopall
    fi
else
    echo "Unable to run script. Please install 'forever' npm package globally."
    exit 1
fi