Run a program as a daemon on OpenBSD

# user add -m /var/server -g _server -s /sbin/nologin _server
# chown -R _server:daemon /var/server
# echo '
#!/bin/ksh

daemon="/usr/local/bin/node /var/server/app.js"
daemon_user="_server"

. /etc/rc.d/rc.subr
rc_bg=YES
rc_cmd $1
' > /etc/rc.d/server
# chmod +x /etc/rc.d/server
# chown root:daemon /etc/rc.d/server
# rcctl start server
server(ok)
# rcctl restart server
server(ok)
server(ok)
# rcctl stop server
server(ok)
#

© RGZ.EE OÜ