Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 ?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

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.

share|improve this answer
    
There was nothing interesting in script output the way you point me. It just write command line history and nothing else. And the logs are empty. –  dima.h Apr 4 '12 at 11:48
    
See my edited answer for more information. We'll get there! –  D_Bye Apr 4 '12 at 13:09
add comment

The pidfile argument is only used by the rc script to check if the process is already running. The script does not create the file for you. The program you're running must create the file itself.

Alternatively you can add the this line to the end of your RC script and the pid file should be created.

echo ${rc_pid} > ${pidfile}
share|improve this answer
    
and it also may be used. thanks. –  dima.h Apr 4 '12 at 17:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.