summaryrefslogtreecommitdiff
path: root/fake-service/fake-user-agent-daemon
blob: 621f463eb022722326f79deb5fab95f891063904 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
export PYTHONPATH=`pwd`/app:$PYTHONPATH

USER_AGENT_PORT=4567

function do_stop() {
        test -e gunicorn.pid && (kill -9 $(cat gunicorn.pid) && rm gunicorn.pid && echo "Stopped User Agent") || echo "User Agent is not running"
}

function do_start() {
        echo "gunicorn pixelated_user_agent:app -b 0.0.0.0:$USER_AGENT_PORT -D -p gunicorn.pid --log-file=gunicorn.log"
        gunicorn pixelated_user_agent:app -b 0.0.0.0:$USER_AGENT_PORT -D -p gunicorn.pid --log-file=gunicorn.log
}

case $1 in
        restart)
                do_stop && do_start
                ;;
        start)
                do_start
                ;;
        stop)
                do_stop
                ;;
        killall)
                pgrep -f gunicorn | xargs kill -9
                rm -rf gunicorn.pid
                ;;
        *)
                echo "usage: start|stop|restart|killall"
                ;;
esac