Hi!

I’m trying to build an rc.d(8) script for a service that does not daemonize on 
OpenBSD 7.6 stable amd64. (Actually the service is a Python script, Radicale 
3.3.0 to be precise.)

Currently everything works but I’m getting a timeout from rcctl start. See 
section Questions below.


Background:
===========
There are ports for Radicale 1.x and 2.x. But unfortunately none for Radicale 
3.x. One of the reasons might be that the -d option for Radicale no longer 
works? I.e. Radicale 3.x can not be made to daemonize.


What I tried:
=============
• Installed python and py3-pip ports.
# pkg_add python py3-pip

• I have installed Radicale 3.3.0 in a Python venv (to avoid mixing up 
pkg_add(1) and pip managed stuff) at /usr/local/lib/radicale.
# python3 -m venv /usr/local/lib/radicale
# /usr/local/lib/radicale/bin/pip install --upgrade pip
# /usr/local/lib/radicale/bin/pip install radicale

• I have created a _radicale user and group identical to the ones created in 
the radicale-2.1.12p7 port.

• Created a minimal config in /etc/radicale/config specifying the storage path 
(/var/db/radicale/collections). Reason: the default path /var/lib/… does not 
exist on OpenBSD.

• Created /var/db/radicale and set its owner and group to _radicale.

• Created the following script and made it executable:
# cat /etc/rc.d/radicale3                                                       
                                                                          
#!/bin/ksh

daemon="/usr/local/lib/radicale/bin/radicale"
daemon_user="_radicale"

. /etc/rc.d/rc.subr

pexp=".* ${daemon}.*"
rc_reload=NO
rc_configtest=NO

rc_cmd $1
# 


Observations:
=============
# rcctl -d start radicale3
doing _rc_parse_conf
radicale3_flags empty, using default ><
doing rc_check
radicale3
doing rc_start
doing _rc_wait_for_start
doing rc_check
No home directory /nonexistent!
Logging in with home = "/".
[2024-10-19 07:47:09 +0200] [43495] [INFO] Logging of backtrace is disabled in 
this loglevel
[2024-10-19 07:47:09 +0200] [43495] [INFO] Logging of backtrace is disabled in 
this loglevel
[2024-10-19 07:47:09 +0200] [43495] [INFO] Loaded default config
[2024-10-19 07:47:09 +0200] [43495] [INFO] Loaded config file 
'/etc/radicale/config'
[2024-10-19 07:47:09 +0200] [43495] [INFO] Skipped missing/unreadable config 
file '/.config/radicale/config'
[2024-10-19 07:47:09 +0200] [43495] [INFO] Starting Radicale
[2024-10-19 07:47:09 +0200] [43495] [WARNING] No user authentication is 
selected: '[auth] type=none' (insecure)
[2024-10-19 07:47:09 +0200] [43495] [INFO] auth type is 'radicale.auth.none'
[2024-10-19 07:47:09 +0200] [43495] [INFO] storage type is 
'radicale.storage.multifilesystem'
[2024-10-19 07:47:09 +0200] [43495] [INFO] rights type is 
'radicale.rights.owner_only'
[2024-10-19 07:47:09 +0200] [43495] [INFO] web type is 'radicale.web.internal'
[2024-10-19 07:47:09 +0200] [43495] [INFO] hook type is 'radicale.hook.none'
[2024-10-19 07:47:09 +0200] [43495] [INFO] permit delete of collection: True
[2024-10-19 07:47:09 +0200] [43495] [INFO] permit overwrite of collection: True
[2024-10-19 07:47:09 +0200] [43495] [INFO] Listening on '127.0.0.1:5232'
[2024-10-19 07:47:09 +0200] [43495] [INFO] Listening on '[::1]:5232'
[2024-10-19 07:47:09 +0200] [43495] [INFO] Radicale server ready
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
Alarm clock
doing _rc_write_runfile
(timeout)
#

# rcctl -d check radicale3
doing _rc_parse_conf
radicale3_flags empty, using default ><
doing _rc_parse_conf /var/run/rc.d/radicale3
radicale3
doing rc_check
(ok)
#

The process is running, everything seems fine. Even `rcctl stop radicale3` 
works fine. `rcctl ls started` lists the service as started. `rcctl ls failed` 
does not list the service. Terminating the terminal session that started the 
service does not stop the service. So there seems to be nothing wrong.


Questions:
==========
1) Why am I getting the repeated `doing rc_check` messages and the timeout when 
starting the service? (But the manual `rcctl check radicale3` works fine.)

2) How can I fix this to not generate a timeout?
Note: I know I could shorten the time this happens by modifying daemon_timeout 
to less than the 30 second default. But I’d still get the timeout.

3) Do I perhaps need to create a wrapper that spawns the actual Radicale 
service and which returns a status of 0? And if so, are there any examples of 
something like this that I could look at for reference?


Other:
======
I think I have looked at all of the relevant man pages and the FAQ. But I 
couldn’t find the answers there. I even tried to understand the rc.subr source 
code. But I’m not sure why the manual check works and the automated check in 
the loop when starting the service doesn’t.

I have other similar situations in mind, where a long (infinitely) running 
script that does not daemonize should be started as a service. I’d like to find 
a general solution if possible.


Thanks!
Mike

Reply via email to