Skip to main content
Topic: Starting ulogd with dinit (Read 410 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Starting ulogd with dinit

I don't know if I'm starting ulogd properly. I have tried two ways: as a bgprocess, and as a regular process

I used this service file for the bgprocess
Code: [Select]
# /etc/dinit.d/ulogd
type            = bgprocess
command         = /usr/bin/ulogd -d
smooth-recovery = true
logfile         = /var/log/dinit/ulogd.log
after           = network
pid-file        = /etc/dinit.d/ulogd.pid

or I used this service file for the regular process
Code: [Select]
# /etc/dinit.d/ulogd
type            = process
command         = /usr/bin/ulogd
smooth-recovery = true
logfile         = /var/log/dinit/ulogd.log
after           = network

In both cases ulogd starts after system startup but its process State is S (sleeping) and /var/log/dinit/ulogd.log has 0 bytes. If I use the service description file with ulogd as bgprocess it does *not* create the pidfile /etc/dinit.d/ulogd.pid, I wonder why.

I any case, I'm not sure which way it is supposed to be run. In both cases the /var/log/dinit/ulogd.log is empty (I guess that means there were no errors with starting it), and ulogd writes its regular logs to /var/log/ulogd.log

Re: Starting ulogd with dinit

Reply #1
I think I now understand the man page of dinit-service a bit better. First I thought that's it's dinit who creates the pid-file and in the service description file we specify where such file should be created - that's what I understood from the bgprocess description in the service type section. However, having also read the bgprocess description in the service properties section, I think it means that the starting program itself writes such a file and dinit only reads it. The service specification file only tells dinit the expected path of this pid file.

The man pages of ulog and sshd now make more sense to me. Ulogd pages write that you can specify the path to the ulogd.pid process (-p option), and in man sshd we learn that a pid file is created in /var/run/sshd.pid (/var/run being the symbolic link to /run). Also the tool audit creates its pid file there. So it seems that the convention for pid file creation is the /run directory and tools that are designed to run as a deamon create their pid files there. Some tools they let you specify where to create the pid files.

So now I'm starting ulogd like this:
Code: [Select]
type            = bgprocess
command         = /usr/bin/ulogd -d -p /run/ulogd.pid
smooth-recovery = true
logfile         = /var/log/dinit/ulogd.log
after           = network
pid-file        = /run/ulogd.pid

But now I don't understand why audit, which is also designed as a deamon process, and which I installed with "pacman -S audit-dinit" has in its default service file the specifications of a normal foreground process and the explicit CLI option -n to make it not deamonize itself. Also audit man pages write that the -n option is useful to run audit off of inittab, which is also an init system, sort-of like the dinit. So now I still don't know if I should be running ulogd as a bgprocess or as a normal process. Also dhcpcd is run the normal way (with the --nobackground parameter). What exactly is going on here?

Re: Starting ulogd with dinit

Reply #2
This is weird. With that version of the service file ulogd started, but somehow wrote pid 0 into its pidfile. The system also could not be rebooted, the kernel did not shut down. So now I use this service file

Code: [Select]
type            = process
command         = /usr/bin/ulogd --loglevel=debug
smooth-recovery = true
logfile         = /var/log/dinit/ulogd.log
after           = network
#pid-file        = /run/ulogd.pid

now it finally seems to work properly. I see a reasonable log output from ulogd. Still not sure why I can't start it as a bgprocess. Similar issues happened with sshd, which I now also start just like a regular process, not bgprosess