Skip to content

Commit 3ad6e63

Browse files
committed
Initial service configuration
1 parent 55b86ce commit 3ad6e63

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

provisioning/etc/gitconsensus/celery

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
# Where does gitconsensus live
3+
CELERY_HOME="/opt/gitconsensus"
4+
5+
# Name of nodes to start
6+
# here we have a single node
7+
CELERYD_NODES="w1"
8+
# or we could have three nodes:
9+
#CELERYD_NODES="w1 w2 w3"
10+
11+
# Absolute or relative path to the 'celery' command:
12+
CELERY_BIN="/opt/gitconsensus/venv/bin/celery"
13+
#CELERY_BIN="/virtualenvs/def/bin/celery"
14+
15+
# App instance to use
16+
# comment out this line if you don't use an app
17+
CELERY_APP="gitconsensusservice.celery"
18+
# or fully qualified:
19+
#CELERY_APP="proj.tasks:app"
20+
21+
# How to call manage.py
22+
CELERYD_MULTI="multi"
23+
24+
# Extra command-line arguments to the worker
25+
CELERYD_OPTS="--time-limit=120 --concurrency=4"
26+
27+
# - %n will be replaced with the first part of the nodename.
28+
# - %I will be replaced with the current child process index
29+
# and is important when using the prefork pool to avoid race conditions.
30+
CELERYD_PID_FILE="/var/run/celery/%n.pid"
31+
CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
32+
CELERYD_LOG_LEVEL="INFO"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Unit]
2+
Description=GitConsensus Service
3+
After=network.target
4+
5+
[Service]
6+
Type=forking
7+
User=gitconsensus
8+
Group=gitconsensus
9+
EnvironmentFile=-/etc/gitconsensus/celery
10+
WorkingDirectory=${CELERY_HOME}
11+
ExecStart=/bin/sh -c 'source ${CELERY_HOME}/venv/bin/activate && ${CELERY_BIN} multi start ${CELERYD_NODES} -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
12+
ExecStop=/bin/sh -c 'source ${CELERY_HOME}/venv/bin/activate && ${CELERY_BIN} multi stopwait ${CELERYD_NODES} --pidfile=${CELERYD_PID_FILE}'
13+
ExecReload=/bin/sh -c 'source ${CELERY_HOME}/venv/bin/activate && ${CELERY_BIN} multi restart ${CELERYD_NODES} -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
14+
15+
[Install]
16+
WantedBy=multi-user.target

provisioning/setup.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ -L "${BASH_SOURCE[0]}" ]]
4+
then
5+
DIR="$( cd "$( dirname $( readlink "${BASH_SOURCE[0]}" ) )" && pwd )"
6+
else
7+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8+
fi
9+
10+
cd $DIR
11+
12+
cp $DIR/etc/systemd/system/gitconsensusworker.service /etc/systemd/system/gitconsensusworker.service
13+
cp $DIR/etc/gitconsensus/celery /etc/gitconsensus/celery
14+
15+
16+
adduser --gecos "" --disabled-login gitconsensus
17+
18+
echo "d /var/run/celery 0755 celery celery -" >> /etc/tmpfiles.d/celery.conf
19+
echo "d /var/log/celery 0755 celery celery - " >> /etc/tmpfiles.d/celery.conf
20+

0 commit comments

Comments
 (0)