#!/bin/sh
### BEGIN INIT INFO
# Provides:          lmsapi
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Run lmsapi
### END INIT INFO

. /lib/init/vars.sh
. /lib/lsb/init-functions



PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin/

do_start() {
	        [ "$VERBOSE" != no ] && log_begin_msg "Start LMSAPI Backend"
		cd /opt/nintegra/LMSAPI 
		APP_SETTINGS=config.DevelopmentConfig gunicorn --bind 127.0.0.1:6001 app:app >> /var/log/lmsapi 2>&1 &
		ES=$?
		[ "$VERBOSE" != no ] && log_end_msg $ES
		return $ES
}

case "$1" in
    start)
	do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
 	killall gunicorn	
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac
