From aa96e3b3cf211896b0895f9f05af6acbad0e3fd1 Mon Sep 17 00:00:00 2001 From: Michael Adams Date: Mon, 24 Sep 2018 18:19:25 -0700 Subject: [PATCH 1/3] Create netbox-rqworker.service Supervisord seems to act up on Ubuntu 18.04.1, at least in a container. Convert that task to a proper systemd service. --- scripts/netbox-rqworker.service | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 scripts/netbox-rqworker.service diff --git a/scripts/netbox-rqworker.service b/scripts/netbox-rqworker.service new file mode 100644 index 000000000..8d5b7601c --- /dev/null +++ b/scripts/netbox-rqworker.service @@ -0,0 +1,17 @@ +# Alternative to using supervisord for running the NetBox Redis Worker +# 1. Create in /etc/systemd/system/netbox-rqworker.service +# 2. systemctl enable netbox-rqworker && systemctl restart netbox-rqworker + +[Unit] +Description=NetBox rqworker + +[Service] +Type=simple +User=netbox +Group=netbox +Environment=LC_ALL=C.UTF-8 LANG=C.UTF-8 +ExecStart=/usr/bin/python3 /opt/netbox/netbox/manage.py rqworker +WorkingDirectory=/opt/netbox/netbox + +[Install] +WantedBy=redis-server.service From 31faaf5af7f82013ed802975376db017990aa1b3 Mon Sep 17 00:00:00 2001 From: Michael Adams Date: Mon, 24 Sep 2018 18:20:50 -0700 Subject: [PATCH 2/3] Create netbox-unit.json Service configuration for use with Nginx Unit --- scripts/netbox-unit.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 scripts/netbox-unit.json diff --git a/scripts/netbox-unit.json b/scripts/netbox-unit.json new file mode 100644 index 000000000..555d065ee --- /dev/null +++ b/scripts/netbox-unit.json @@ -0,0 +1,17 @@ +{ + "listeners": { + "*:8001": { + "application": "netbox" + } + }, + "applications": { + "netbox": { + "type": "python 3.6", + "user": "netbox", + "group": "netbox", + "processes": 2, + "path": "/opt/netbox/netbox/", + "module": "netbox.wsgi" + } + } +} From bee16ef752e5170010bafd4d7fb5e21244bd2219 Mon Sep 17 00:00:00 2001 From: Michael Adams Date: Mon, 24 Sep 2018 18:47:16 -0700 Subject: [PATCH 3/3] Create nunit-redis-install.sh Editable script to handle the migration from supervisord and gunicorn, to Nginx Unit + systemd --- scripts/nunit-redis-install.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 scripts/nunit-redis-install.sh diff --git a/scripts/nunit-redis-install.sh b/scripts/nunit-redis-install.sh new file mode 100644 index 000000000..747247baf --- /dev/null +++ b/scripts/nunit-redis-install.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# 1. Install Nginx Unit from https://unit.nginx.org/installation/ before running this. +# 2. Check the other files to replace the "netbox" user, if using "www-data" or something else. +# 3. chmod u+rx nunit-redis-install.sh && sudo ./nunit-redis-install.sh + +# Remove supervisord & gunicorn, if only used for NetBox +# apt remove supervisor gunicorn -y && apt autoremove -y + +# Load Redis Worker service +cp -f netbox-rqworker.service /etc/systemd/system/ +systemctl enable netbox-rqworker && systemctl restart netbox-rqworker + +# Load NUnit config +systemctl enable unit && systemctl restart unit +sudo apt install curl -y +sudo curl -X PUT -d @netbox-unit.json --unix-socket /var/control.unit.sock http://localhost/config/