forked from netbox-community/netbox
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes netbox-community#2902 - Migrate to systemd from supervisord
- Loading branch information
Showing
8 changed files
with
154 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[Unit] | ||
Description=Netbox RQ Worker | ||
Documentation=https://netbox.readthedocs.io/en/stable/ | ||
After=network-online.target | ||
Wants=network-online.target | ||
|
||
[Service] | ||
Type=simple | ||
|
||
EnvironmentFile=/etc/sysconfig/netbox | ||
|
||
User=$User | ||
Group=$Group | ||
|
||
WorkingDirectory=$WorkingDirectory | ||
|
||
ExecStart=/usr/bin/python3 $WorkingDirectory/netbox/manage.py rqworker | ||
|
||
Restart=on-failure | ||
RestartSec=30 | ||
PrivateTmp=true | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Name is the Process Name | ||
# | ||
Name = 'Netbox' | ||
|
||
# WorkingDirectory is the Working Directory for Netbox. | ||
# | ||
WorkingDirectory='/usr/local/netbox/' | ||
|
||
# User is the user the Netbox WSGI should run as | ||
# | ||
User='www-data' | ||
|
||
# Group is the group the Netbox WSGI should run as | ||
# | ||
Group='www-data' | ||
|
||
|
||
# PidPath is the path to the pid for the netbox WSGI | ||
# | ||
PidPath='/var/run/netbox.pid' | ||
|
||
# Bind is the ip and port that the Netbox WSGI should bind to | ||
# | ||
# Bind='127.0.0.1:8001' | ||
|
||
# Workers is the number of workers that GUnicorn should spawn. | ||
# Workers should be: cores * 2 + 1. So if you have 8 cores, it would be 17. | ||
# | ||
Workers=3 | ||
|
||
# Threads | ||
# The number of threads for handling requests | ||
# | ||
Threads=3 | ||
|
||
# Timeout is the timeout | ||
# | ||
Timeout=120 | ||
|
||
# ErrorLog | ||
# ErrorLog is the logfile for the ErrorLog | ||
# | ||
# ErrorLog='/usr/local/netbox/netbox.log' | ||
|
||
# CaptureOutput | ||
# CaptureOutput is a binary option about whether stdout/stderr should be sent to the ErrorLog | ||
# | ||
# CaptureOutput=False |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[Unit] | ||
Description=Netbox WSGI | ||
Documentation=https://netbox.readthedocs.io/en/stable/ | ||
After=network-online.target | ||
Wants=network-online.target | ||
|
||
[Service] | ||
Type=simple | ||
|
||
EnvironmentFile=/etc/sysconfig/netbox | ||
|
||
User=$User | ||
Group=$Group | ||
PIDFile=$PidPath | ||
WorkingDirectory=$WorkingDirectory | ||
|
||
ExecStart=/usr/bin/gunicorn --pid $PidPath --bind $Bind --workers $Workers --timeout $Timeout --errorlog $ErrorLog --capture_output $CaptureOutput netbox.wsgi | ||
|
||
Restart=on-failure | ||
RestartSec=30 | ||
PrivateTmp=true | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Migration | ||
|
||
## Ubuntu | ||
|
||
### Remove supervisord: | ||
|
||
```no-highlight | ||
# apt-get remove -y supervisord | ||
``` | ||
|
||
### systemd configuration: | ||
|
||
Copy or link contrib/netbox@.service and contrib/netbox-rq to /etc/systemd/system/netbox@.service and /etc/systemd/system/netbox-rq.service | ||
|
||
```no-highlight | ||
# copy contrib/netbox@.service to /etc/systemd/system/netbox@.service | ||
# copy contrib/netbox-rq.service to /etc/systemd/system/netbox-rq.service | ||
``` | ||
|
||
Copy contrib/netbox.env to /etc/sysconfig/netbox.env | ||
|
||
```no-highlight | ||
# mkdir /etc/sysconfig/netbox.env | ||
# copy contrib/netbox.env to /etc/sysconfig/netbox.env | ||
``` | ||
|
||
Edit /etc/sysconfig/netbox.env and change the settings as required | ||
|
||
```no-highlight | ||
# vi /etc/sysconfig/netbox.env | ||
``` | ||
|
||
Then, restart the systemd daemon service to detect the netbox service and start the netbox service: | ||
|
||
```no-highlight | ||
# systemctl daemon-reload | ||
# systemctl start netbox.service | ||
# systemctl enable netbox.service | ||
# systemctl start netbox-rq.service | ||
# systemctl enable netbox-rq.service | ||
``` |
This file contains 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