forked from netbox-community/netbox
-
Notifications
You must be signed in to change notification settings - Fork 0
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 * Closes netbox-community#2902 - Migrate to systemd from supervisord * Update systemd unit and environment file * Add gunicorn.conf * Update documentation and CHANGELOG. Moved parameters around on service file * Update Gitignore
- Loading branch information
Showing
11 changed files
with
308 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
fabfile.py | ||
*.swp | ||
gunicorn_config.py | ||
gunicorn.conf | ||
netbox.log | ||
netbox.pid | ||
.DS_Store | ||
.vscode | ||
.coverage |
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,22 @@ | ||
# 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 between gunicorn receiving a request and returning a response (or failing with a 500 error) | ||
# | ||
timeout=120 | ||
|
||
# ErrorLog | ||
# ErrorLog is the logfile for the ErrorLog | ||
# | ||
errorlog='/opt/netbox/netbox.log' |
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.env | ||
|
||
User=www-data | ||
Group=www-data | ||
|
||
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,15 @@ | ||
# Name is the Process Name | ||
# | ||
Name = 'Netbox' | ||
|
||
# ConfigPath is the path to the gunicorn config file. | ||
# | ||
ConfigPath=/opt/netbox/gunicorn.conf | ||
|
||
# WorkingDirectory is the Working Directory for Netbox. | ||
# | ||
WorkingDirectory=/opt/netbox/ | ||
|
||
# PidPath is the path to the pid for the netbox WSGI | ||
# | ||
PidPath=/opt/netbox/netbox.pid |
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.env | ||
|
||
User=www-data | ||
Group=www-data | ||
PIDFile=${PidPath} | ||
WorkingDirectory=${WorkingDirectory} | ||
|
||
ExecStart=/usr/local/bin/gunicorn --pid ${PidPath} --pythonpath ${WorkingDirectory}/netbox --config ${ConfigPath} 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
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.%i.env | ||
|
||
User=www-data | ||
Group=www-data | ||
PIDFile=${PidPath} | ||
WorkingDirectory=${WorkingDirectory} | ||
|
||
ExecStart=/usr/local/bin/gunicorn --pid ${PidPath} --pythonpath ${WorkingDirectory}/netbox --config ${ConfigPath} 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,105 @@ | ||
# Migration | ||
|
||
Migration is not required, as supervisord will still continue to function. | ||
|
||
## Ubuntu | ||
|
||
### Remove supervisord: | ||
|
||
```no-highlight | ||
# apt-get remove -y supervisord | ||
``` | ||
|
||
### systemd configuration: | ||
|
||
Copy or link contrib/netbox.service and contrib/netbox-rq.service to /etc/systemd/system/netbox.service and /etc/systemd/system/netbox-rq.service | ||
|
||
```no-highlight | ||
# cp contrib/netbox.service /etc/systemd/system/netbox.service | ||
# cp contrib/netbox-rq.service /etc/systemd/system/netbox-rq.service | ||
``` | ||
|
||
Edit /etc/systemd/system/netbox.service and /etc/systemd/system/netbox-rq.service. Be sure to verify the location of the gunicorn executable on your server (e.g. `which gunicorn`). If using CentOS/RHEL. Change the username from `www-data` to `nginx` or `apache`: | ||
|
||
```no-highlight | ||
/usr/local/bin/gunicorn --pid ${PidPath} --pythonpath ${WorkingDirectory}/netbox --config ${ConfigPath} netbox.wsgi | ||
``` | ||
|
||
```no-highlight | ||
User=www-data | ||
Group=www-data | ||
``` | ||
|
||
Copy contrib/netbox.env to /etc/sysconfig/netbox.env | ||
|
||
```no-highlight | ||
# cp contrib/netbox.env /etc/sysconfig/netbox.env | ||
``` | ||
|
||
Edit /etc/sysconfig/netbox.env and change the settings as required. Update the `WorkingDirectory` variable if needed. | ||
|
||
```no-highlight | ||
# Name is the Process Name | ||
# | ||
Name = 'Netbox' | ||
# ConfigPath is the path to the gunicorn config file. | ||
# | ||
ConfigPath=/opt/netbox/gunicorn.conf | ||
# WorkingDirectory is the Working Directory for Netbox. | ||
# | ||
WorkingDirectory=/opt/netbox/ | ||
# PidPath is the path to the pid for the netbox WSGI | ||
# | ||
PidPath=/var/run/netbox.pid | ||
``` | ||
|
||
Copy contrib/gunicorn.conf to gunicorn.conf | ||
|
||
```no-highlight | ||
# cp contrib/gunicorn.conf to gunicorn.conf | ||
``` | ||
|
||
Edit gunicorn.conf and change the settings as required. | ||
|
||
``` | ||
# 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 between gunicorn receiving a request and returning a response (or failing with a 500 error) | ||
# | ||
timeout=120 | ||
# ErrorLog | ||
# ErrorLog is the logfile for the ErrorLog | ||
# | ||
errorlog='/opt/netbox/netbox.log' | ||
``` | ||
|
||
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 | ||
``` | ||
|
||
If using webhooks, also start the Redis worker: | ||
|
||
```no-highlight | ||
# systemctl start netbox-rq.service | ||
# systemctl enable netbox-rq.service | ||
``` |
Oops, something went wrong.