Freebsd pid file not created

freebsdpid

Pid files not created in /var/run folder.

rc.d script:

#!/bin/sh

. /etc/rc.subr

name=phpcgi
rcvar=phpcgi_enable
pidfile=/var/run/${name}.pid
command=/usr/local/bin/php-cgi

load_rc_config $name
run_rc_command "$1"

it's working fine but the problem is with pid file. it can not find it when i try to "service phpcgi stop". permissions are correct. how can i fix it ?

Best Answer

Try turning on tracing to make the script tell you what it is doing at each step. You'll get lots of output, so I'd recommend capturing it using a script session. Replace the first line of the script with

#!/bin/sh -x

and then run:

# script phpcgi-trace
# service phpcgi start
# service phpcgi stop
# ^D

The file phpcgi-trace will contain a record of everything that the script tries to do. Search through it for clues as to why it's not dropping a pidfile.

EDIT

Note that the pidfile= line in the rc script is there to tell rc how to check the status of the controlled program, or how to stop it. It's not there to tell rc to write a pidfile - that's the responsibility of the controlled program.

If phpcgi doesn't write a pidfile when it starts, the easiest thing to do is to just omit the pidfile= line, and let rc use the process name to check status, etc.

Related Topic