Skip to content

Commit e4eafdb

Browse files
committed
Deployment updates
1 parent 8b87942 commit e4eafdb

File tree

10 files changed

+180
-6
lines changed

10 files changed

+180
-6
lines changed

conf_templates/celery.service

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Unit]
2+
Description=%(PROJECT_NAME)s celery (backend)
3+
After=nginx.service redis-server.service
4+
5+
[Service]
6+
User=%(USER)s
7+
Group=%(GROUP)s
8+
PIDFile=/run/celery.pid
9+
ExecStart=%(DEPLOY_DIR)s/conf/celery.sh
10+
StartLimitInterval=60
11+
ExecReload=/bin/kill -s HUP $MAINPID
12+
ExecStop=/bin/kill -s TERM $MAINPID
13+
PrivateTmp=true
14+
15+
[Install]
16+
# When should this service be triggered? (this is the equivalent of SysV's runlevel 3)
17+
WantedBy=multi-user.target

conf_templates/celery.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
LOG_DIR="%(DEPLOY_DIR)s/logs"
6+
LOG_FILE="$LOG_DIR/celery.log"
7+
8+
test -d "$LOG_DIR" || mkdir -p "$LOG_DIR"
9+
cd "%(DEPLOY_DIR)s"
10+
11+
source %(ENV_PATH)s/bin/activate
12+
source %(ENV_PATH)s/bin/postactivate
13+
export DJANGO_SETTINGS_MODULE="%(SETTINGS_MODULE)s"
14+
15+
exec celery -A steepshot_io worker -E -c 3 --loglevel=DEBUG --logfile="$LOG_FILE"

conf_templates/gunicorn.conf

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
description "%(PROJECT_NAME)s webserver (backend)"
2+
start on runlevel [2345]
3+
stop on runlevel [06]
4+
respawn
5+
respawn limit 10 5
6+
exec %(DEPLOY_DIR)s/conf/gunicorn.sh

conf_templates/gunicorn.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
LOG_DIR="%(DEPLOY_DIR)s/logs"
6+
LOG_FILE="$LOG_DIR/gunicorn.log"
7+
8+
test -d "$LOG_DIR" || mkdir -p "$LOG_DIR"
9+
cd "%(DEPLOY_DIR)s"
10+
11+
source %(ENV_PATH)s/bin/activate
12+
source %(ENV_PATH)s/bin/postactivate
13+
export DJANGO_SETTINGS_MODULE="%(SETTINGS_MODULE)s"
14+
15+
exec gunicorn --pythonpath "%(DEPLOY_DIR)s" \
16+
--bind "%(GUNI_HOST)s:%(GUNI_PORT)s" \
17+
--workers "%(GUNI_WORKERS)s" \
18+
--timeout "%(GUNI_TIMEOUT)s" \
19+
--graceful-timeout "%(GUNI_GRACEFUL_TIMEOUT)s" \
20+
--worker-class "gaiohttp" \
21+
--user "%(USER)s" \
22+
--group "%(GROUP)s" \
23+
--log-level "info" \
24+
--log-file "$LOG_FILE" \
25+
steepshot_io.wsgi:application

conf_templates/nginx.conf.j2

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
server {
2+
server_name {{ CURRENT_HOST }};
3+
4+
{%-if ENV == "VAGRANT" %}
5+
listen 80;
6+
{%- else %}
7+
listen 443 ssl;
8+
{%- endif %}
9+
10+
{%-if ENV == "VAGRANT" %}
11+
{# Do not use certificates on vagrant installation #}
12+
{%- else %}
13+
ssl_certificate /etc/ssl/certs/www.steepshot.io.certchain.crt;
14+
ssl_certificate_key /etc/ssl/private/steepshot.io.key;
15+
{%- endif %}
16+
17+
access_log {{ DEPLOY_DIR }}/logs/nginx-access.log;
18+
error_log {{ DEPLOY_DIR }}/logs/nginx-error.log;
19+
20+
client_max_body_size 10M;
21+
22+
if ($http_host != $server_name) {
23+
return 400 $http_host;
24+
}
25+
26+
location {{ STATIC_URL }} {
27+
add_header 'Access-Control-Allow-Origin' '*';
28+
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
29+
add_header 'Access-Control-Allow-Headers' 'X-Requested-With,Accept,Content-Type, Origin';
30+
alias {{ STATIC_ROOT }}/;
31+
}
32+
33+
location {{ MEDIA_URL }} {
34+
add_header 'Access-Control-Allow-Origin' '*';
35+
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
36+
add_header 'Access-Control-Allow-Headers' 'X-Requested-With,Accept,Content-Type, Origin';
37+
alias {{ MEDIA_ROOT}}/;
38+
}
39+
40+
location / {
41+
if ($request_method = 'OPTIONS') {
42+
43+
add_header 'Access-Control-Allow-Origin' "$http_origin";
44+
45+
add_header 'Access-Control-Allow-Credentials' 'true';
46+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
47+
48+
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
49+
50+
add_header 'Access-Control-Max-Age' 1728000;
51+
add_header 'Content-Type' 'text/plain charset=UTF-8';
52+
add_header 'Content-Length' 0;
53+
54+
return 204;
55+
}
56+
57+
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
58+
add_header 'Access-Control-Allow-Credentials' 'true' always;
59+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
60+
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept,Origin' always;
61+
62+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
63+
{% if ENV != "VAGRANT" %}
64+
proxy_set_header X-Forwarded-Proto http;
65+
{% else %}
66+
proxy_set_header X-Forwarded-Proto https;
67+
{% endif %}
68+
proxy_set_header Host $http_host;
69+
proxy_redirect off;
70+
proxy_pass http://localhost:{{ GUNI_PORT }};
71+
}
72+
}
73+
74+
{% if ENV != "VAGRANT" %}
75+
server {
76+
server_name www.{{ CURRENT_HOST }}
77+
www.{{ HOST }};
78+
return 301 https://{{ CURRENT_HOST }}$request_uri;
79+
}
80+
81+
server {
82+
server_name {{ HOST }};
83+
listen 443 ssl;
84+
return 301 https://{{ CURRENT_HOST }}$request_uri;
85+
}
86+
87+
server {
88+
server_name {{ CURRENT_HOST }}
89+
{{ HOST }};
90+
listen 80;
91+
return 301 https://{{ CURRENT_HOST }}$request_uri;
92+
}
93+
{% endif %}

conf_templates/steepshot_io.service

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Unit]
2+
Description=%(PROJECT_NAME)s webserver (backend)
3+
Before=nginx.service
4+
After=postgresql.service
5+
6+
[Service]
7+
User=%(USER)s
8+
Group=%(GROUP)s
9+
PIDFile=/run/steepshot_io.pid
10+
ExecStart=%(DEPLOY_DIR)s/conf/gunicorn.sh
11+
StartLimitInterval=60
12+
ExecReload=/bin/kill -s HUP $MAINPID
13+
ExecStop=/bin/kill -s TERM $MAINPID
14+
PrivateTmp=true
15+
16+
[Install]
17+
# When should this service be triggered? (this is the equivalent of SysV's runlevel 3)
18+
WantedBy=multi-user.target

fabfile.py

-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ def install_service(service_name, context):
255255
Copies and enables specified systemd service
256256
to the remote server.
257257
"""
258-
import pdb; pdb.set_trace() # XXX BREAKPOINT
259258
logger.info('Copying systemd services "%s"', service_name)
260259
remote_service = _get_systemd_service_path(service_name)
261260
local_template = os.path.join(LOCAL_CONF_DIR, service_name)

steepshot_io/config/prod_settings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
else:
4242
ALLOWED_HOSTS = []
4343

44-
PROJECT_NAME = 'steepshot.io'
44+
PROJECT_NAME = 'steepshot_io'
4545

4646
STEEM_NODE = 'wss://steemd.steemit.com'
4747
GOLOS_NODE = 'wss://ws.golos.io'
@@ -66,7 +66,7 @@
6666
'django.contrib.messages',
6767
'django.contrib.staticfiles',
6868

69-
'steepshot_io.core',
69+
'core',
7070
]
7171

7272
MIDDLEWARE = [

steepshot_io/deploy_settings.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
REPOSITORY = 'https://github.com/Chainers/steepshot.io'
1212

13-
PROJECT_NAME = 'steepshot.io'
13+
PROJECT_NAME = 'steepshot_io'
1414

1515

1616
# We use non-root user for better security
@@ -73,8 +73,8 @@
7373
GUNI_TIMEOUT = 60
7474
GUNI_GRACEFUL_TIMEOUT = 180
7575

76-
SETTINGS_MODULE = 'steepshot_io.config.prod_settings'
77-
GOLOS_SETTINGS_MODULE = 'steepshot_io.config.golos_prod_settings'
76+
SETTINGS_MODULE = 'config.prod_settings'
77+
GOLOS_SETTINGS_MODULE = 'config.golos_prod_settings'
7878

7979

8080
ENVIRONMENTS = {

steepshot_io/static/main.css

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
body {}

0 commit comments

Comments
 (0)