From 734f10a19bf2e3619ca7f2fb0c429a7b05083d5b Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 26 Apr 2016 19:07:17 +0800 Subject: [PATCH] logs document logrotate configuration for lwsws After discussion here https://libwebsockets.org/pipermail/libwebsockets/2016-April/002304.html Signed-off-by: Andy Green --- README.lwsws.md | 46 ++++++++++++++++++++++ lwsws/etc-logrotate.d-lwsws | 10 +++++ lwsws/usr-lib-systemd-system-lwsws.service | 11 ++++++ 3 files changed, 67 insertions(+) create mode 100644 lwsws/etc-logrotate.d-lwsws create mode 100644 lwsws/usr-lib-systemd-system-lwsws.service diff --git a/README.lwsws.md b/README.lwsws.md index 82227fdf..28cf5c14 100644 --- a/README.lwsws.md +++ b/README.lwsws.md @@ -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 index 00000000..cc92a9ac --- /dev/null +++ b/lwsws/etc-logrotate.d-lwsws @@ -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 index 00000000..dfa36de3 --- /dev/null +++ b/lwsws/usr-lib-systemd-system-lwsws.service @@ -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 +