Skip to content

Commit

Permalink
new convention
Browse files Browse the repository at this point in the history
  • Loading branch information
agahkarakuzu committed Sep 4, 2024
1 parent 721fae6 commit 2c55b30
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __pycache__/
*.lock
build_locks/
celery_preview/
neurolibre_celery_session/
# Distribution / packaging
.Python
build/
Expand Down
2 changes: 1 addition & 1 deletion api/start_celery.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
source /home/ubuntu/venv/neurolibre38/bin/activate
source ${VENV_PATH}/bin/activate
exec "$@"
5 changes: 3 additions & 2 deletions systemd/default/celery
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
CUSTOM_START="/home/ubuntu/full-stack-server/api/start_celery.sh"
VENV_PATH="/home/ubuntu/venv/neurolibre38"
CELERY_BIN="${VENV_PATH}/bin/celery"
CELERYD_NODES="w1 w2"
CELERY_APP="neurolibre_celery_tasks"
CELERYD_MULTI="multi"
CELERYD_OPTS="--time-limit=300 --concurrency=8"
CELERYD_PID_FILE="/home/ubuntu/full-stack-server/api/celery_preview/run/celery/%n.pid"
CELERYD_LOG_FILE="/home/ubuntu/full-stack-server/api/celery_preview/log/celery/%n%I.log"
CELERYD_PID_FILE="/home/ubuntu/full-stack-server/api/neurolibre_celery_session/run/celery/%n.pid"
CELERYD_LOG_FILE="/home/ubuntu/full-stack-server/api/neurolibre_celery_session/log/celery/%n%I.log"
CELERYD_LOG_LEVEL="INFO"
22 changes: 18 additions & 4 deletions systemd/neurolibre-preview.service
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
[Unit]
Description=Neurolibre preview server
Description=Neurolibre Task Manager
After=network.target

[Service]
Type=forking
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/full-stack-server/api
Environment="PATH=$PATH:/home/ubuntu/venv/neurolibre/bin"
EnvironmentFile=/etc/default/celery
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${VENV_PATH}/bin"
Environment=GIT_PYTHON_GIT_EXECUTABLE=/usr/bin/git
ExecStart=/home/ubuntu/venv/neurolibre/bin/gunicorn --workers 4 --bind unix:/home/ubuntu/full-stack-server/api/neurolibre_preview_api.sock -m 007 wsgi_preview:app
Restart=always
Environment=CELERY_CREATE_DIRS=1
ExecStart=/bin/sh -c '${CUSTOM_START} ${CELERY_BIN} -A ${CELERY_APP} multi start ${CELERYD_NODES} \
--pidfile="${CELERYD_PID_FILE}" \
--logfile="${CELERYD_LOG_FILE}" \
--loglevel="${CELERYD_LOG_LEVEL}" \
${CELERYD_OPTS}'
ExecStop=/bin/sh -c '${CUSTOM_START} ${CELERY_BIN} -A ${CELERY_APP} multi stopwait ${CELERYD_NODES} \
--pidfile="${CELERYD_PID_FILE}"'
ExecReload=/bin/sh -c '${CUSTOM_START} ${CELERY_BIN} -A ${CELERY_APP} multi restart ${CELERYD_NODES} \
--pidfile="${CELERYD_PID_FILE}" \
--logfile="${CELERYD_LOG_FILE}" \
--loglevel="${CELERYD_LOG_LEVEL}" \
${CELERYD_OPTS}'
Restart=on-failure

[Install]
WantedBy=multi-user.target

0 comments on commit 2c55b30

Please sign in to comment.