logs document logrotate configuration for lwsws
authorAndy Green <andy@warmcat.com>
Tue, 26 Apr 2016 11:07:17 +0000 (19:07 +0800)
committerAndy Green <andy@warmcat.com>
Tue, 26 Apr 2016 11:07:17 +0000 (19:07 +0800)
After discussion here

https://libwebsockets.org/pipermail/libwebsockets/2016-April/002304.html

Signed-off-by: Andy Green <andy@warmcat.com>
README.lwsws.md
lwsws/etc-logrotate.d-lwsws [new file with mode: 0644]
lwsws/usr-lib-systemd-system-lwsws.service [new file with mode: 0644]

index 82227fd..28cf5c1 100644 (file)
@@ -310,3 +310,49 @@ And map the provided HTML into the vhost in the mounts section
 You might choose to put it on its own vhost which has "interface": "lo", so it's not
 externally visible.
 
+
+Integration with Systemd
+------------------------
+
+lwsws needs a service file like this as `/usr/lib/systemd/system/lwsws.service`
+
+```
+[Unit]
+Description=Libwebsockets Web Server
+After=syslog.target
+
+[Service]
+ExecStart=/usr/local/bin/lwsws
+StandardError=null
+
+[Install]
+WantedBy=multi-user.target
+
+```
+
+You can find this prepared in `./lwsws/usr-lib-systemd-system-lwsws.service`
+
+
+Integration with logrotate
+--------------------------
+
+For correct operation with logrotate, `/etc/logrotate.d/lwsws` (if that's
+where we're putting the logs) should contain
+
+```
+/var/log/lwsws/*log {
+    copytruncate
+    missingok
+    notifempty
+    delaycompress
+}
+```
+
+You can find this prepared in `/lwsws/etc-logrotate.d-lwsws`
+
+Prepare the log directory like this
+
+```
+sudo mkdir /var/log/lwsws
+sudo chmod 700 /var/log/lwsws
+```
diff --git a/lwsws/etc-logrotate.d-lwsws b/lwsws/etc-logrotate.d-lwsws
new file mode 100644 (file)
index 0000000..cc92a9a
--- /dev/null
@@ -0,0 +1,10 @@
+/var/log/lwsws/*log {
+    copytruncate
+    missingok
+    notifempty
+    delaycompress
+    postrotate
+        /bin/systemctl reload lwsws.service > /dev/null 2>/dev/null || true
+    endscript
+}
+
diff --git a/lwsws/usr-lib-systemd-system-lwsws.service b/lwsws/usr-lib-systemd-system-lwsws.service
new file mode 100644 (file)
index 0000000..dfa36de
--- /dev/null
@@ -0,0 +1,11 @@
+[Unit]
+Description=Libwebsockets Web Server
+After=syslog.target
+
+[Service]
+ExecStart=/usr/local/bin/lwsws
+StandardError=null
+
+[Install]
+WantedBy=multi-user.target
+