Custom rc script using /usr/sbin/daemon
Hello, I'm trying to create a script that would launch php-cgi in fastcgi mode. So far, I've the following script : #!/bin/sh # # PROVIDE: phpfastcgi # REQUIRE: DAEMON # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf to enable phpfastcgi : # # phpfastcgi_enable (bool): Set it to YES to enable phpfastcgi # Default is NO. # phpfastcgi_flags (str): Set the uwsgi command line arguments # Default is -M -L. . /etc/rc.subr name=phpfastcgi rcvar=`set_rcvar` [ -z $phpfastcgi_enable ] phpfastcgi_enable=NO [ -z $phpfastcgi_flags ] phpfastcgi_flags= load_rc_config $name sig_stop=TERM pidfile=/var/run/${name}/${name}.pid command=/usr/sbin/daemon -f -p ${pidfile} /usr/local/bin/php-cgi run_rc_command $1 When invoked with start argument, it barfs at me but launches php-cgi as expected : e...@srvbsdfenssv:~ sudo /usr/local/etc/rc.d/phpfastcgi start /usr/local/etc/rc.d/phpfastcgi: WARNING: no shebang line in /usr/sbin/daemon [: /usr/sbin/daemon: unexpected operator Starting phpfastcgi. When invoked with stop argument, it errors and doesn't stop the process as expected : e...@srvbsdfenssv:~ sudo /usr/local/etc/rc.d/phpfastcgi stop /usr/local/etc/rc.d/phpfastcgi: WARNING: no shebang line in /usr/sbin/daemon phpfastcgi not running? (check /var/run/phpfastcgi/phpfastcgi.pid). From a quick peek at /etc/rc.subr, it seems that messages regarding lack of shebang line in /usr/sbin/daemon indicate something is wrong in my script but atm, I can't figure it. Any idea, anyone ? Kind Regards Éric Masson -- RJ j'ai eu des cookies sur mon HD et j'ai un peu peur des représailles Il faut reformater ton disque dur et le jetter depuis le 3e étage de la tour Eiffel pour le détruire irrémédiablement sans laisser de traces. -+- LP in http://www.le-gnu.net : Par ici ou parano c'est pareil -+- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Custom rc script using /usr/sbin/daemon
On Tue, 05 Oct 2010 13:18:38 +0200 Eric Masson e...@free.fr wrote: Hello, I'm trying to create a script that would launch php-cgi in fastcgi mode. So far, I've the following script : ... sig_stop=TERM pidfile=/var/run/${name}/${name}.pid command=/usr/sbin/daemon -f -p ${pidfile} /usr/local/bin/php-cgi I don't think you can do it like that. IIRC when you try to stop a daemon it doesn't just kill the process by pid, it also sanity checks the command in case the daemon has died and the pid was reused. Since daemon wont show-up in the ps output it can't be in the command variable. I think you need to write a start function, something like this: start_cmd=phpfastcgi_start command=/usr/local/bin/php-cgi phpfastcgi_start(){ echo starting phpfastcgi. /usr/sbin/daemon -f -p ${pidfile} ${command} } ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Custom rc script using /usr/sbin/daemon
RW rwmailli...@googlemail.com writes: Hello, I don't think you can do it like that. IIRC when you try to stop a daemon it doesn't just kill the process by pid, it also sanity checks the command in case the daemon has died and the pid was reused. Since daemon wont show-up in the ps output it can't be in the command variable. Ok, makes sense. I think you need to write a start function, something like this: start_cmd=phpfastcgi_start command=/usr/local/bin/php-cgi phpfastcgi_start(){ echo starting phpfastcgi. /usr/sbin/daemon -f -p ${pidfile} ${command} } Fine, it works much better now. Thanks a lot Kind Regards Éric Masson -- je n'ai jamais repondu aux AAD car je pensais qu'on pouvais pas en tant que personne qui propose un newgroup... -+- A in GNU : C'est quoi un groupe de discussion d'ailleurs ? -+- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org