Question about daemon and pidfile

Hello Team,

I have issue to start gitea since multiple weeks (months). Here is the issue : I am unable to start gitea via the rc script (using freebsd 13.4 & freebsd 13.5 via jail from TrueNas).

When using the following command :

sh:
service gitea start

I have a slight delay then the prompt appears, once I try to check the service status with :

sh:
service gitea status

The following message appears :
sh:
gitea is not running.

After digging into the rc.d script (located in /usr/local/etc/rc.d/gitea), the daemon command uses the -p pidfile :

sh:
gitea_start() {

        for d in /var/db/gitea /var/log/gitea; do
                if [ ! -e "$d" ]; then
                        mkdir "$d"
                        chown ${gitea_user} "$d"
                fi
        done

        /usr/sbin/daemon -S -l ${gitea_facility} -s ${gitea_priority} -T ${name} \
                -u ${gitea_user} -p ${pidfile} \
                -l daemon -s warning \
                /usr/bin/env -i \
                "GITEA_WORK_DIR=${gitea_shared}" \
                "GITEA_CUSTOM=${gitea_custom}" \
                "HOME=${githome}" \
}

I also tried to rebuild the given command to be more user friendly to debug :

sh:
/usr/sbin/daemon -S -l daemon -s info -T gitea -u git -p /var/run/gitea.pid /usr/bin/env -i 'GITEA_WORK_DIR=/usr/local/share/gitea' 'GITEA_CUSTOM=/usr/local/etc/gitea' 'HOME=/usr/local/git' 'PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' 'USER=git' /usr/local/sbin/gitea web

Nothing appears, only the blinking prompt :/

Regards,

Nikos
 
Funny idea perhaps, but have you considered it might have failed to start? Just because you started the service doesn't mean it's actually running.
 
Yeah, the service(8) command only checks if it successfully started the process. But the process itself could fail and die at a later stage.
 
In general, service(8) often provides the status* sub-command (and that uses ps(1) I think); also:
Code:
EXIT STATUS
       The service utility exits 0 on success, and >0 if an error occurs.

Sometimes, trying to leverage ps | grep (e.g. in succession), seems a bit harder:
Rich (BB code):
[20-0] # service ntpd stop
Stopping ntpd.
Waiting for PIDS: 21605.
[21-0] # ps | grep ntpd
21658  3  S+   0:00.00 grep ntpd

___
* Using status, as compared to ps | grep, can make it easier to use in certain circomstances as it has a nice result code:
Rich (BB code):
[1-0] # service ntpd stop
Stopping ntpd.
Waiting for PIDS: 1613.
[2-0] # service ntpd status
ntpd is not running.
[3->1<] # echo $?
1
[4-0] # service ntpd start
Starting ntpd.
[5-0] # service ntpd status
ntpd is running as pid 21605.
[6-0] # echo $?
0
 
Hello Team,

I was able to troubleshoot my issue, after inspection this script is correct, instead, it is the daemon binary which seems to be faulty in TrueNas (I used jail with FreeBSD 13.4 & 13.5, even with 13.2 it failed).

Once the latest TrueNas patch applied (13.3u1 today), I was able to start normally my gitea instance.

Thanks for your input (if needed, I can add a link regarding the daemon issue from TrueNas forum).

Best regards,

Nikos
 
In general, service(8) often provides the status* sub-command (and that uses ps(1) I think); also:
I think status is always provided, it's implemented in rc.subr(8). It indeed uses ps(1), but also the pidfile if the service uses one, which is a best practice because it makes sure to find the correct running instance (the pid read from the pidfile is then passed as an argument to ps(1) to only check for that specific pid).
 
sh:
gitea_start() {

        for d in /var/db/gitea /var/log/gitea; do
                if [ ! -e "$d" ]; then
                        mkdir "$d"
                        chown ${gitea_user} "$d"
                fi
        done

        /usr/sbin/daemon -S -l ${gitea_facility} -s ${gitea_priority} -T ${name} \
                -u ${gitea_user} -p ${pidfile} \
                -l daemon -s warning \
                /usr/bin/env -i \
                "GITEA_WORK_DIR=${gitea_shared}" \
                "GITEA_CUSTOM=${gitea_custom}" \
                "HOME=${githome}" \
}
Is that the whole of gitea_start()? The daemon command doesn't actually do anything and ends is a continuation character, but you do have the closing brace, which suggests this might not be a simple copy and paste error.
 
Back
Top