From e172a8a5374ff6ecc419849dddbef2826ed08852 Mon Sep 17 00:00:00 2001 From: dmorina Date: Fri, 3 Mar 2017 15:18:34 -0800 Subject: [PATCH] add systemd services and nginx base config --- nginx-dev.conf | 37 +++++++++++++++++++++++++++++++++++++ systemd/celery.service | 11 +++++++++++ systemd/uwsgi_web.service | 14 ++++++++++++++ systemd/uwsgi_ws.service | 14 ++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 nginx-dev.conf create mode 100644 systemd/celery.service create mode 100644 systemd/uwsgi_web.service create mode 100644 systemd/uwsgi_ws.service diff --git a/nginx-dev.conf b/nginx-dev.conf new file mode 100644 index 00000000..3ee50736 --- /dev/null +++ b/nginx-dev.conf @@ -0,0 +1,37 @@ +# Add this to the main nginx.conf +#gzip on; +#gzip_disable "msie6"; +#gzip_vary on; +#gzip_proxied any; +#gzip_comp_level 6; +#gzip_types text/plain application/javascript application/octet-stream text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon; +#gzip_min_length 256; + + +# this config should be in the sites-enabled, use /usr/local prefix if nginx is installed under that directory otherwise remove this prefix from the directories below +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + charset utf-8; + # root /var/www/html; + client_max_body_size 64M; + #index index.html index.htm index.nginx-debian.html; + + location /static { + alias /usr/local/var/www/daemo/; + } + + location / { + uwsgi_pass unix:/var/tmp/webserver.socket; + include /usr/local/etc/nginx/uwsgi_params; + # try_files $uri $uri/ =404; + } + + location /ws/ { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://unix:/var/tmp/websockets.socket; + } +} diff --git a/systemd/celery.service b/systemd/celery.service new file mode 100644 index 00000000..c66ed8c8 --- /dev/null +++ b/systemd/celery.service @@ -0,0 +1,11 @@ +[Unit] +Description=Celery background tasks for Daemo +After=network.target + +[Service] +User=celery +Group=celery +ExecStart=/bin/bash -c 'cd /daemo; /usr/local/bin/celery -A csp worker -l info -B' + +[Install] +WantedBy=multi-user.target diff --git a/systemd/uwsgi_web.service b/systemd/uwsgi_web.service new file mode 100644 index 00000000..4b60f750 --- /dev/null +++ b/systemd/uwsgi_web.service @@ -0,0 +1,14 @@ +[Unit] +Description=uWSGI instance to serve Daemo API +After=syslog.target + +[Service] +ExecStart=/bin/bash -c 'cd /daemo; /usr/local/bin/uwsgi --socket /var/tmp/webserver.socket --buffer-size=32768 --workers=5 --master --module csp.webserver --chmod-socket=666 --chown-socket=www-data:www-data' +Restart=always +KillSignal=SIGQUIT +Type=notify +StandardError=syslog +NotifyAccess=all + +[Install] +WantedBy=multi-user.target diff --git a/systemd/uwsgi_ws.service b/systemd/uwsgi_ws.service new file mode 100644 index 00000000..d8adcfe2 --- /dev/null +++ b/systemd/uwsgi_ws.service @@ -0,0 +1,14 @@ +[Unit] +Description=uWSGI instance to serve web sockets +After=syslog.target + +[Service] +ExecStart=/bin/bash -c 'cd /daemo; /usr/local/bin/uwsgi --http-socket /var/tmp/websockets.socket --gevent=1000 --http-websockets --workers=2 --master --module csp.websockets --chmod-socket=666 --chown-socket=www-data:www-data' +Restart=always +KillSignal=SIGQUIT +Type=notify +StandardError=syslog +NotifyAccess=all + +[Install] +WantedBy=multi-user.target