Browse Source

distrib: refine OpenRC init scripts

- Add logging to init script
- Add delay so OpenRC realises if we crashed quickly b/c of e.g. bad config
   file
- General cleanups (like supporting multiple instances, style changes)

This should make it a lot easier to see what's going wrong when something
breaks.

Bug: ergochat/ergo#1914
Signed-off-by: Sam James <sam@gentoo.org>
tags/v2.10.0-rc1
Sam James 2 years ago
parent
commit
7c766b2096
No account linked to committer's email address
2 changed files with 18 additions and 4 deletions
  1. 1
    0
      distrib/openrc/ergo.confd
  2. 17
    4
      distrib/openrc/ergo.initd

+ 1
- 0
distrib/openrc/ergo.confd View File

@@ -1,2 +1,3 @@
1 1
 # /etc/conf.d/ergo: config file for /etc/init.d/ergo
2 2
 ERGO_CONFIGFILE="/etc/ergo/ircd.yaml"
3
+ERGO_USERNAME="ergo"

+ 17
- 4
distrib/openrc/ergo.initd View File

@@ -1,17 +1,30 @@
1 1
 #!/sbin/openrc-run
2
+name=${RC_SVCNAME}
3
+description="ergo IRC daemon"
4
+
2 5
 command=/usr/bin/ergo
3
-command_args="run --conf ${ERGO_CONFIGFILE:-"/etc/ergo/ircd.yaml"}"
6
+command_args="run --conf ${ERGO_CONFIGFILE:-'/etc/ergo/ircd.yaml'}"
7
+command_user=${ERGO_USERNAME:-ergo}
4 8
 command_background=true
9
+
10
+pidfile=/var/run/${RC_SVCNAME}.pid
11
+
12
+output_log="/var/log/${RC_SVCNAME}.out"
13
+error_log="/var/log/${RC_SVCNAME}.err"
14
+# --wait: to wait 1 second after launching to see if it survived startup
15
+start_stop_daemon_args="--wait 1000"
16
+
5 17
 extra_started_commands="reload"
6
-pidfile=/var/run/ergo.pid
7
-name="ergo"
8
-description="ergo IRC daemon"
9 18
 
10 19
 depend() {
11 20
 	use dns
12 21
 	provide ircd
13 22
 }
14 23
 
24
+start_pre() {
25
+	checkpath --owner ${command_user}:${command_user} --mode 0640 --file /var/log/${RC_SVCNAME}.out /var/log/${RC_SVCNAME}.err
26
+}
27
+
15 28
 reload() {
16 29
 	ebegin "Reloading ${RC_SVCNAME}"
17 30
 	start-stop-daemon --signal HUP --pidfile "${pidfile}"

Loading…
Cancel
Save