check-services.sh 1018 Bytes
Newer Older
root's avatar
root committed
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
#!/bin/bash
SERVICES=('celery worker' 'celery beat')
PID_DIR='/var/run/celery/helios'
  
for service in "${SERVICES[@]}"; do
    if ps ax | grep -v grep | grep "$service" > /dev/null
    then
        echo "$service service running, everything is fine"
    else
        echo "$service is not running"

        cd /mnt/data/www/helios && \
        source /mnt/data/environments/helios/bin/activate

        if [[ ! -e $PID_DIR ]]; then
            mkdir -p $PID_DIR
            chown www-helios:ifs00sv012-helios-rw $PID_DIR
        fi

        if [ "$service" == "celery worker" ]; then
            celery multi start worker -A helios -l INFO --concurrency=5 -f /var/log/uwsgi/helios/celery-worker.log --pidfile=/var/run/celery/helios/celery-worker.pid --uid=www-helios --gid=ifs00sv012-helios-rw
        else
            celery beat -A helios -l INFO -f /var/log/uwsgi/helios/celery-beat.log --pidfile=/var/run/celery/helios/celery-beat.pid --uid=www-helios --gid=ifs00sv012-helios-rw &
        fi

    fi
done
exit 0