To create new wiki account, please join us on #znc at Libera.Chat and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.
Daemontools
ZNC is so called "daemon", that means a program that runs in background and provides services, without need of direct user interaction.
Daemontools is a package of tools for managing such daemons. It's features includes:
- Starting / stopping
- Restarting on crash
- Managing logfiles
- Managing resource limits
- Setting user / group priviliges
Deamontools overview
svscan & supervise
Which deamons to run is configured by simple directory structure. The main directory, usually called service. This directory contains one subdirectory per each service to be managed.
Each service needs one run file which execute the service and optionaly log/run subservice, that handles logging of output of the service.
svscan program watches service directory and makes sure every service has running supervise program. These programs in turn make sure actual service is up and running.
Each service is immediately restarted whenever it exits. Znc should be run with --foreground flag, so supervise knows when to restart it.
You can use svstat to look at the status of services and svc to bring the service up or down.
multilog
multilog reads a sequence of lines f/rom stdin and appends selected lines to any number of logs. That means you can make znc log to files that are automatically rotated, without any copy/truncate magic.
Configuration trivia:
- when destination is a directory (ends with a slash), log files are autorotated
- s<number> argument specifies number of bytes after which file should be rotated
- n<number arguments number of rotated log files to keep
For detailed manual, see [1] or man multilog.
User setup example
I have following setup on my server, all set up to run under my personal account.
~/service/znc/run
#!/bin/bash exec znc --foreground --debug 2>&1
~/service/znc/log/run
#!/bin/bash exec /usr/bin/multilog t s2500000 n10 ~/log/znc
Of course you have to start svscan somehow. On restricted shell accounts you usually don't have access to start-up scripts. As a workaround cron daemon is often used. Vixie-cron and derived variants allow use of @reboot field instead of time specification to run programs at startup. For more info type man 5 crontab in your shell.
crontab
@reboot /usr/bin/svscan ${HOME}/service