Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

A ton of addedd stuff #78

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0214390
updating README
May 10, 2017
463992f
add optionable send of notification for resolved incidents
May 10, 2017
40ab5ad
add HipChat notification method
May 10, 2017
c471874
add better notification logging and result keeping
May 10, 2017
dba9d0c
add unacknowledge backend code
May 10, 2017
2359793
update requirements.txt for hipchat, django-debug-toolbar and securit…
May 10, 2017
d45c1af
add incident endpoint for API as an alias to create_event
May 10, 2017
30a1442
add django-debug-toolbar to settings and urls if DEBUG==True
May 10, 2017
1b2eaea
add better error management for hipchat and default settings.py config
May 10, 2017
b6fe592
fix email notifier to be able to use custom SMTP servers; add default…
May 10, 2017
8b7d61c
modify user notif_method template for better visibility
May 10, 2017
116cf33
front-end: add cosmetic glyphicons to menus; add confirmation before …
May 10, 2017
bde6341
add optional TLS for SMTP email notifier
May 11, 2017
1b54188
add UNACK support in incidents.py
May 12, 2017
fb706dd
notification tasks return result for easier debugging with Flower
May 12, 2017
aae607b
add more verbose errors from incidents.py and send resolve notifications
May 12, 2017
bab0a4a
add escalate_to_service: the possibility to escalate(basically send, …
May 12, 2017
db2c490
fix extra space in openduty/models.py
May 12, 2017
3dd4786
add the option to notify groups of people in escalation rules, events…
May 12, 2017
77f1382
add the option to search by incident_key with autosuggest for the lat…
May 12, 2017
1644473
add example systemd service files
May 12, 2017
5dddc86
add example nginx conf for reverse rpoxy to gunicorn
May 12, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ now, you can start hacking on it.
# Running as a service with systemd
*OpenDuty can be ran as a service with the help of gunicorn and systemd*
```
cp systemd/gunicorn.service /etc/systemd/system/
cp -r systemd/gunicorn.service.d /etc/systemd/system/gunicorn.service.d
cp -r systemd/gunicorn.service.* /etc/systemd/system/

cp systemd/celery.service /etc/systemd/system/
cp -r systemd/celery.service.d /etc/systemd/system/
cp -r systemd/celery.service* /etc/systemd/system/

// EDIT VARIABLES IN *.service.d/main.conf TO REFLECT YOUR ENV
vi /etc/systemd/system/gunicorn.service.d/main.conf
vi /etc/systemd/system/celery.service.d/main.conf

systemctl daemon-reload
sudo systemctl start gunicorn
Expand Down
14 changes: 14 additions & 0 deletions systemd/celery.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Celery daemon
After=network.target gunicorn.service

[Service]
ExecStart=/bin/sh -c "/$WorkingDirectory/env/bin/celery worker --uid=$User --gid=$Group --logfile=$LogFile --loglevel=info --pidfile=$PIDFile --autoscale=2,1 --app=openduty --workdir=/$WorkingDirectory"
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

7 changes: 7 additions & 0 deletions systemd/celery.service.d/main.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Service]
Environment="User=www-data"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just set the User= option?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, all of these should likely be set as actual systemd options, not as environment variables:

Group=
PidFile=
WorkingDirectory

Setting these in environment variables, and then spawning a shell so that you can consume them as environment variables actually leads to less configurability in the long run.

A lot of this could be solved by setting Type=forking to let systemd know to just use it's default behavior for a forking process.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I'll take this PR and try to work on improving some of the systemd-isms this week.

Environment="Group=www-data"
Environment="PIDFile=/run/openduty/celery.pid"
Environment="WorkingDirectory=usr/local/bin/openduty"
Environment="LogFile=/var/log/openduty/celery.log"

14 changes: 14 additions & 0 deletions systemd/flower.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Flower Service
After=network.target celery.service

[Service]
ExecStart=/bin/sh -c "/$WorkingDirectory/env/bin/python /$WorkingDirectory/env/bin/flower --app=openduty --port=5555 --logfile=$LogFile --loglevel=info --pidfile=$PIDFile --workdir=/$WorkingDirectory --url_prefix=flower"
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Restart=always
RestartSec=3


[Install]
WantedBy=multi-user.target
7 changes: 7 additions & 0 deletions systemd/flower.service.d/main.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Service]
Environment="User=www-data"
Environment="Group=www-data"
Environment="PIDFile=/run/openduty/flower.pid"
Environment="WorkingDirectory=usr/local/bin/openduty"
Environment="LogFile=/var/log/openduty/flower.log"
Environment="ErrorFiles=/var/log/openduty/flower.error.log"
20 changes: 20 additions & 0 deletions systemd/gunicorn.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Unit]
Description=gunicorn daemon
After=network.target

[Service]
PermissionsStartOnly=true
User=www-data
Group=www-data
ExecStartPre=/bin/mkdir -p /var/run/openduty/
ExecStartPre=/bin/chown -R www-data:www-data /var/run/openduty
ExecStart=/bin/sh -c "/$WorkingDirectory/env/bin/gunicorn --user=$User --workers=9 --pid=$PIDFile --log-file=$LogFile --log-level=Debug --capture-output --error-logfile=$ErrorLogFile --chdir=$WorkingDirectory --bind 0.0.0.0:8080 openduty.wsgi:application"
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target


8 changes: 8 additions & 0 deletions systemd/gunicorn.service.d/main.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Service]
Environment="User=www-data"
Environment="Group=www-data"
Environment="PIDFile=/run/openduty/gunicorn.pid"
Environment="WorkingDirectory=usr/local/bin/openduty"
Environment="LogFile=/var/log/openduty/gunicorn.log"
Environment="ErrorLogFile=/var/log/openduty/gunicorn.error.log"