Skip to content

Commit 9d05517

Browse files
committed
Added systemd service info to production install docs
1 parent 4be42a3 commit 9d05517

File tree

1 file changed

+118
-3
lines changed

1 file changed

+118
-3
lines changed

docs/running-in-production.rst

Lines changed: 118 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,27 @@ Running in Production
33

44
This guide will walk you through how to setup DefectDojo for running in production using Ubuntu 16.04, nginx, and uwsgi.
55

6-
*Install, Setup, and Activate Virtualenv*
6+
**Install, Setup, and Activate Virtualenv**
7+
8+
Assumes running as root or using sudo command for the below.
79

810
.. code-block:: console
911
1012
pip install virtualenv
1113
14+
cd /opt
15+
1216
virtualenv dojo
17+
18+
cd /opt/dojo
19+
20+
git clone https://github.com/DefectDojo/django-DefectDojo.git
21+
22+
useradd -m dojo
23+
24+
chown -R dojo /opt/dojo
1325
14-
source dojo/bin/activate
26+
source ./bin/activate
1527
1628
**Install Dojo**
1729

@@ -66,7 +78,7 @@ However, for a quick setup you can use the following to run both in the backgrou
6678
6779
celery beat -A dojo -l info &
6880
69-
*Start Uwsgi*
81+
**Start Uwsgi**
7082

7183
From inside the django-DefectDojo/ directory execute:
7284

@@ -80,6 +92,45 @@ It is recommended that you use an Upstart job or a @restart cron job to launch u
8092
8193
uwsgi --socket :8001 --wsgi-file wsgi.py --workers 7 &
8294
95+
**Making Defect Dojo start on boot**
96+
97+
Below we configure service files for systemd. The commands follow, the config files are below the Nginx in the next section.
98+
99+
.. code-block:: console
100+
101+
cd /etc/systemd/system/
102+
103+
vi dojo.service
104+
[contents below]
105+
106+
systemctl enable dojo
107+
108+
systemctl start dojo
109+
110+
systemctl status dojo
111+
[ensure it launched OK]
112+
113+
vi celery-worker.service
114+
[contents below]
115+
116+
systemctl enable celery-worker
117+
118+
systemctl start celery-worker
119+
120+
systemctl status celery-worker
121+
[ensure it launched OK]
122+
123+
vi celery-beat.service
124+
[contents below]
125+
126+
systemctl enable celery-beat
127+
128+
systemctl start celery-beat
129+
130+
systemctl status celery-beat
131+
[ensure it launched OK]
132+
133+
83134
*NGINX Configuration*
84135

85136
Everyone feels a little differently about nginx settings, so here are the barebones to add your to your nginx configuration to proxy uwsgi. Make sure to modify the filesystem paths if needed:
@@ -122,4 +173,68 @@ Everyone feels a little differently about nginx settings, so here are the barebo
122173
}
123174
}
124175
176+
*Systemd Configuration Files*
177+
178+
dojo.service
179+
180+
.. code-block:: console
181+
182+
[Unit]
183+
Description=uWSGI instance to serve DefectDojo
184+
Requires=nginx.service mysql.service
185+
Before=nginx.service
186+
After=mysql.service
187+
188+
[Service]
189+
ExecStart=/bin/bash -c 'su - dojo -c "cd /opt/dojo/django-DefectDojo && source ../bin/activate && uwsgi --socket :8001 --wsgi-file wsgi.py --workers 7"'
190+
Restart=always
191+
RestartSec=3
192+
#StandardOutput=syslog
193+
#StandardError=syslog
194+
SyslogIdentifier=dojo
195+
196+
[Install]
197+
WantedBy=multi-user.target
198+
199+
celery-worker.service
200+
201+
.. code-block:: console
202+
203+
[Unit]
204+
Description=celery workers for DefectDojo
205+
Requires=dojo.service
206+
After=dojo.service
207+
208+
[Service]
209+
ExecStart=/bin/bash -c 'su - dojo -c "cd /opt/dojo/django-DefectDojo && source ../bin/activate && celery -A dojo worker -l info --concurrency 3"'
210+
Restart=always
211+
RestartSec=3
212+
#StandardOutput=syslog
213+
#StandardError=syslog
214+
SyslogIdentifier=celeryworker
215+
216+
[Install]
217+
WantedBy=multi-user.target
218+
219+
celery-beat.service
220+
221+
.. code-block:: console
222+
223+
[Unit]
224+
Description=celery beat for DefectDojo
225+
Requires=dojo.service
226+
After=dojo.service
227+
228+
[Service]
229+
ExecStart=/bin/bash -c 'su - dojo -c "cd /opt/dojo/django-DefectDojo && source ../bin/activate && celery beat -A dojo -l info"'
230+
Restart=always
231+
RestartSec=3
232+
#StandardOutput=syslog
233+
#StandardError=syslog
234+
SyslogIdentifier=celerybeat
235+
236+
[Install]
237+
WantedBy=multi-user.target
238+
239+
125240
*That's it!*

0 commit comments

Comments
 (0)