Saturday, December 09, 2023

Re: Dealing with daemons that don't behave like daemons in rc scripts

On Sat, Dec 09, 2023 at 01:03:31PM +0000, Edd Barrett wrote:
> (If we are fine with the general approach, and if this is something that we are
> going to need to do for other ports, perhaps it would be better for rc.d to
> have some kind of built-in support for using a daemon-wrapper? I don't know)

Maybe that'd look something like this:

```
--- rc.subr.orig Sat Dec 9 18:28:27 2023
+++ rc.subr Sat Dec 9 18:44:51 2023
@@ -174,7 +174,7 @@
}

rc_start() {
- rc_exec "${daemon} ${daemon_flags}"
+ rc_exec "${daemon_wrapper:+${daemon_wrapper} }${daemon} ${daemon_flags}"
}
```

With a rc script looking like this:

```
#!/bin/ksh

daemon="/usr/local/bin/navidrome"
daemon_user="_navidrome"
daemon_flags="-c /etc/navidrome.toml"
daemon_wrapper="/usr/local/sbin/daemon"

. /etc/rc.d/rc.subr

rc_reload=NO

rc_cmd $1
```

(Still doesn't start right when `daemon_logger` is set though)

--
Best Regards
Edd Barrett

https://www.theunixzoo.co.uk

No comments:

Post a Comment