Last active
August 29, 2015 13:56
-
-
Save o3bvv/9250092 to your computer and use it in GitHub Desktop.
Example settings for il2ec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python interpreter from environment. | |
ENV_PYTHON="/var/virtualenvs/il2ec/bin/python" | |
# Name of nodes to start | |
# here we have a single node | |
CELERYD_NODES="w1" | |
# or we could have three nodes: | |
# CELERYD_NODES="w1 w2 w3" | |
# Full path to the Django project directory. | |
CELERYD_CHDIR="/var/virtualenvs/il2ec/src/il2ec" | |
# 5 minute hard time limit for tasks + enable events at startup. | |
CELERYD_OPTS="--time-limit=300 -E -B --concurrency=1" | |
CELERYD_MULTI="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryd_multi" | |
CELERYD_STATUS="$ENV_PYTHON $CELERYD_CHDIR/manage.py celery status" | |
# %n will be replaced with the nodename. | |
CELERYD_LOG_FILE="/var/log/celery/%n.log" | |
CELERYD_PID_FILE="/var/run/celery/%n.pid" | |
# Workers should run as an unprivileged user. | |
CELERYD_USER="vagrant" | |
CELERYD_GROUP="www-data" | |
# celerybeat | |
CELERYBEAT_USER="$CELERYD_USER" | |
CELERYBEAT_GROUP="$CELERYD_GROUP" | |
CELERYBEAT="$ENV_PYTHON $CELERYD_CHDIR/manage.py celerybeat" | |
CELERYBEAT_OPTS="-S djcelery.schedulers.DatabaseScheduler" | |
CELERYBEAT_LOG_FILE="/var/log/celery/beat.log" | |
CELERYBEAT_PID_FILE="/var/run/celery/beat.pid" | |
# celeryevcam | |
CELERYEV="$CELERYD_CHDIR/manage.py celeryev" | |
CELERYEV_USER="$CELERYD_USER" | |
CELERYEV_GROUP="$CELERYD_GROUP" | |
CELERYEV_CAM="djcelery.snapshot.Camera" | |
CELERYEV_LOG_FILE="/var/log/celery/evcam.log" | |
CELERYEV_PID_FILE="/var/run/celery/evcam.pid" | |
export DJANGO_SETTINGS_MODULE="il2ec.settings.vagrant" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# ============================================ | |
# celeryd - Starts the Celery worker daemon. | |
# ============================================ | |
# | |
# :Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status} | |
# :Configuration file: /etc/default/celeryd | |
# | |
# See http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-init-scripts | |
### BEGIN INIT INFO | |
# Provides: celeryd | |
# Required-Start: $network $local_fs $remote_fs | |
# Required-Stop: $network $local_fs $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: celery task worker daemon | |
### END INIT INFO | |
#set -e | |
DEFAULT_PID_FILE="/var/run/celeryd@%n.pid" | |
DEFAULT_LOG_FILE="/var/log/celeryd@%n.log" | |
DEFAULT_LOG_LEVEL="INFO" | |
DEFAULT_NODES="celery" | |
DEFAULT_CELERYD="-m celery.bin.celeryd_detach" | |
# /etc/init.d/celeryd: start and stop the celery task worker daemon. | |
CELERY_DEFAULTS=${CELERY_DEFAULTS:-"/etc/default/celeryd"} | |
test -f "$CELERY_DEFAULTS" && . "$CELERY_DEFAULTS" | |
if [ -f "/etc/default/celeryd" ]; then | |
. /etc/default/celeryd | |
fi | |
CELERYD_PID_FILE=${CELERYD_PID_FILE:-${CELERYD_PIDFILE:-$DEFAULT_PID_FILE}} | |
CELERYD_LOG_FILE=${CELERYD_LOG_FILE:-${CELERYD_LOGFILE:-$DEFAULT_LOG_FILE}} | |
CELERYD_LOG_LEVEL=${CELERYD_LOG_LEVEL:-${CELERYD_LOGLEVEL:-$DEFAULT_LOG_LEVEL}} | |
CELERYD_MULTI=${CELERYD_MULTI:-"celeryd-multi"} | |
CELERYD=${CELERYD:-$DEFAULT_CELERYD} | |
CELERYD_NODES=${CELERYD_NODES:-$DEFAULT_NODES} | |
export CELERY_LOADER | |
if [ -n "$2" ]; then | |
CELERYD_OPTS="$CELERYD_OPTS $2" | |
fi | |
CELERYD_LOG_DIR=`dirname $CELERYD_LOG_FILE` | |
CELERYD_PID_DIR=`dirname $CELERYD_PID_FILE` | |
if [ ! -d "$CELERYD_LOG_DIR" ]; then | |
mkdir -p $CELERYD_LOG_DIR | |
fi | |
if [ ! -d "$CELERYD_PID_DIR" ]; then | |
mkdir -p $CELERYD_PID_DIR | |
fi | |
# Extra start-stop-daemon options, like user/group. | |
if [ -n "$CELERYD_USER" ]; then | |
DAEMON_OPTS="$DAEMON_OPTS --uid=$CELERYD_USER" | |
chown "$CELERYD_USER" $CELERYD_LOG_DIR $CELERYD_PID_DIR | |
fi | |
if [ -n "$CELERYD_GROUP" ]; then | |
DAEMON_OPTS="$DAEMON_OPTS --gid=$CELERYD_GROUP" | |
chgrp "$CELERYD_GROUP" $CELERYD_LOG_DIR $CELERYD_PID_DIR | |
fi | |
if [ -n "$CELERYD_CHDIR" ]; then | |
DAEMON_OPTS="$DAEMON_OPTS --workdir=\"$CELERYD_CHDIR\"" | |
fi | |
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" | |
check_dev_null() { | |
if [ ! -c /dev/null ]; then | |
echo "/dev/null is not a character device!" | |
exit 1 | |
fi | |
} | |
ensure_dir() { | |
if [ -d "$1" ]; then | |
mkdir -p "$1" | |
chown $CELERYD_USER:$CELERYD_GROUP "$1" | |
chmod 02755 "$1" | |
fi | |
} | |
check_paths() { | |
ensure_dir "$(dirname $CELERYD_PID_FILE)" | |
ensure_dir "$(dirname $CELERYD_LOG_FILE)" | |
} | |
stop_workers () { | |
$CELERYD_MULTI stop $CELERYD_NODES --pidfile="$CELERYD_PID_FILE" | |
} | |
start_workers () { | |
$CELERYD_MULTI start $CELERYD_NODES $DAEMON_OPTS \ | |
--pidfile="$CELERYD_PID_FILE" \ | |
--logfile="$CELERYD_LOG_FILE" \ | |
--loglevel="$CELERYD_LOG_LEVEL" \ | |
--cmd="$CELERYD" \ | |
$CELERYD_OPTS | |
} | |
restart_workers () { | |
$CELERYD_MULTI restart $CELERYD_NODES $DAEMON_OPTS \ | |
--pidfile="$CELERYD_PID_FILE" \ | |
--logfile="$CELERYD_LOG_FILE" \ | |
--loglevel="$CELERYD_LOG_LEVEL" \ | |
--cmd="$CELERYD" \ | |
$CELERYD_OPTS | |
} | |
case "$1" in | |
start) | |
check_dev_null | |
check_paths | |
start_workers | |
;; | |
stop) | |
check_dev_null | |
check_paths | |
stop_workers | |
;; | |
reload|force-reload) | |
echo "Use restart" | |
;; | |
status) | |
$CELERYD_STATUS | |
;; | |
restart) | |
check_dev_null | |
check_paths | |
restart_workers | |
;; | |
try-restart) | |
check_dev_null | |
check_paths | |
restart_workers | |
;; | |
*) | |
echo "Usage: /etc/init.d/celeryd {start|stop|restart|try-restart|kill}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of uWSGI settings for running Django application | |
# /etc/uwsgi/conf.d/il2ec-staging.ini | |
[uwsgi] | |
virtualenv=/home/il2ec-dev/.virtualenvs/il2ec | |
chdir=/home/il2ec-dev/projects/il2ec | |
touch-reload = /tmp/uwsgi-touch-reload-il2ec | |
socket = 127.0.0.1:9001 | |
module = il2ec.wsgi:application | |
workers = 2 | |
# publish statistics at port 1717 | |
stats = :1717 | |
# show memory consumption in logfile | |
memory-report = true | |
# enable master process manager | |
master = true | |
# automatically kill workers on master's death | |
no-orphans = true | |
# place timestamps into log | |
log-date = true | |
# user identifier of uWSGI processes | |
uid = il2ec-dev | |
# group identifier of uWSGI processes | |
gid = il2ec-dev | |
# reload a worker if it takes more than 60 seconds to respond | |
harakiri = 60 | |
# reload a worker if it consumes more than 512 megs of address space or | |
# 480 megs of unshared physical memory | |
reload-on-as = 512 | |
reload-on-rss = 480 | |
# enable post buffering, so if worker is killed due to harakiri mode | |
# post requests will work ok | |
post-buffering = 8192 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example Nginix settings for serving web application | |
# /etc/nginx/conf.d/il2ec.conf | |
server { | |
listen 80; | |
# listen 443 ssl; | |
server_name localhost ""; | |
# ssl_certificate certificate.crt; | |
# ssl_certificate_key certificate.pem; | |
ssl_protocols SSLv2 SSLv3 TLSv1; | |
ssl_ciphers HIGH:!aNULL:!MD5; | |
ssl_prefer_server_ciphers on; | |
location /uploads { | |
alias /home/il2ec-dev/.virtualenvs/il2ec/var/uploads/; | |
expires off; | |
} | |
location /static { | |
alias /home/il2ec-dev/.virtualenvs/il2ec/var/static/; | |
gzip_comp_level 1; | |
gzip_proxied any; | |
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
expires off; | |
} | |
location /favicon.ico { | |
alias /home/il2ec-dev/.virtualenvs/il2ec/var/static/favicon.ico; | |
expires off; | |
} | |
location / { | |
uwsgi_pass 127.0.0.1:9001; | |
include uwsgi_params; | |
expires off; | |
} | |
} | |
log_format combined_timed '$remote_addr - $remote_user [$time_local] ' | |
'"$request" $status $body_bytes_sent ' | |
'"$http_referer" "$http_user_agent" ' | |
'$request_time $upstream_response_time $gzip_ratio'; | |
access_log /var/log/nginx/il2ec-access.log combined_timed; | |
client_max_body_size 250m; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of Nginx global settings | |
# /etc/nginx/nginx.conf | |
user il2ec-dev; | |
worker_processes 2; | |
pid /run/nginx.pid; | |
error_log /var/log/nginx/error.log info; | |
events { | |
worker_connections 1024; | |
# multi_accept on; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /var/log/nginx/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
keepalive_timeout 65; | |
#gzip on; | |
include /etc/nginx/conf.d/*.conf; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of supervisor service for running uWSGI | |
# /etc/supervisor/conf.d/uwsgi.conf | |
[program:uwsgi] | |
command=/home/il2ec-dev/.virtualenvs/il2ec/bin/uwsgi --ini /etc/uwsgi/conf.d/il2ec-staging.ini | |
environment=DJANGO_SETTINGS_MODULE='il2ec.settings.staging' | |
numprocs=1 | |
numprocs_start=0 | |
priority=999 | |
autostart=true | |
autorestart=unexpected | |
startsecs=1 | |
startretries=3 | |
exitcodes=0,2 | |
stopsignal=TERM | |
stopwaitsecs=10 | |
killasgroup=false | |
user=root | |
redirect_stderr=false | |
stdout_logfile=/var/log/supervisor/uwsgi/uwsgi.out | |
stdout_logfile_maxbytes=250MB | |
stdout_logfile_backups=10 | |
stderr_logfile=/var/log/supervisor/uwsgi/uwsgi.err | |
stderr_logfile_maxbytes=250MB | |
stderr_logfile_backups=10 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment