Solved Startup script not found

I am trying to adapt the script found here to my purposes:

Initially I followed the instructions and put the script in /etc/rc.local but the script was then being triggered before nginx and mysql loaded. I need it to be triggered after those services are loaded. I decided to try to follow rc and rc.subr documentation and try to adapt the script to those conventions, but then I ran into an error that seems to occur when there are hyphens in the name. I removed the hyphens, but now my console is just printing the following during boot (although it appears to be in the right boot order):

Code:
Usage: /etc/rc {(re)start|status|stop}



My /etc/rc.conf:
Code:
ifconfig_em0="inet 10.10.20.111 netmask 255.255.0.0"
defaultrouter="10.10.0.1"
sshd_enable="YES"
ntpdate_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
firewall_enable="YES"
firewall_quiet="YES"
firewall_type="workstation"
firewall_myservices="22/tcp 80/tcp 443/tcp"
firewall_allowservices="any"
firewall_logdeny="YES"
mysql_enable="YES"
nginx_enable="YES"
spawnfcgirt_enable="YES"

My script /usr/local/etc/rc.d/spawn-fcgi-rt:
Code:
#!/bin/sh
# REQUIRE: NETWORKING nginx mysql
# PROVIDE: spawnfcgirt

# Modified spawn-fcgi for rc.d (original: vivek@nixcraft.com)
# https://www.nginx.com/resources/wiki/start/topics/examples/freebsdspawnfcgi/

. /etc/rc.subr

name="spawnfcgirt"
rcvar="${name}_enable"
SPAWNFCGI=/usr/local/bin/spawn-fcgi
PROCESS_NAME=rt-server
SERVER_SOCKET=/var/run/rt/rt-fcgi.sock
SERVER_PID=/tmp/fcgi.pid
SERVER_USER=www
SERVER_GROUP=www
FCGI_PROCESS=/opt/rt5/sbin/rt-server.fcgi
SOCKSTAT=/usr/bin/sockstat
GREP=/usr/bin/grep
#KILLALL=/usr/bin/killall
KILL=/bin/kill
cmd=$1
fcgi_restart()
{
        fcgi_stop
        fcgi_start
}
fcgi_start()
{
        $SPAWNFCGI -s $SERVER_SOCKET -P $SERVER_PID -u $SERVER_USER -g $SERVER_GROUP -- $FCGI_PROCESS
}
fcgi_stop()
{
        $KILL -9 `cat $SERVER_PID`
}
fcgi_status()
{
        $SOCKSTAT -u | $GREP -i $SERVER_SOCKET > /dev/null
        [ $? -eq 0  ] && echo "$PROCESS_NAME is running" || echo "$PROCESS_NAME is not running!"
}
fcgi_help()
{
        echo "Usage: $0 {(re)start|status|stop}"
}
case ${cmd} in
[Rr][Ee][Ss][Tt][Aa][Rr][Tt]) fcgi_restart;;
[Ss][Tt][Aa][Rr][Tt]) fcgi_start;;
[Ss][Tt][Oo][Pp]) fcgi_stop;;
[Ss][Tt][Aa][Tt][Uu][Ss]) fcgi_status;;
*) fcgi_help;;
esac

Can somebody point me in the right direction to properly modify the spawn-fcgi script provided by Nginx so that it loads automatically at startup AFTER nginx and mysql?
 
Are you not over complicating things ?
Write a script start_fpm_nginx with following code
Code:
service php-fpm onestart
service nginx onestart
With php-fpm running on port 127.0.0.1:9000, my nginx.conf contains
Code:
location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
 
Are you not over complicating things ?
Write a script start_fpm_nginx with following code
Code:
service php-fpm onestart
service nginx onestart
With php-fpm running on port 9000, my nginx.conf contains
Code:
location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
I'm not running PHP, I'm running rt, which is Perl. Basically trying to follow their instructions:

 
Can somebody point me in the right direction to properly modify the spawn-fcgi script provided by Nginx so that it loads automatically at startup AFTER nginx and mysql?
Have you looked at rcorder(8)?
Also grep REQUIRE /etc/rc.d/* /usr/local/etc/rc.d/* will tell you a lot.
The lowercase REQUIREs are rc script names.
The UPPERCASE "placeholders" are explained in rc(8).
 
You can debug this by placing 'echo "Usage: $0 {(re)start|status|stop} cmd is now $1"' in function fcgi_help(). I guess that you will have to remove the hyphens from the file name in /usr/local/etc/rc.d too.
 
I have. I'm not sure what I'm supposed to gather from those resources. It's still not obvious to me what I'm doing wrong.
Sorry, I should have taken a closer look at your original post.

I would check ownership and permissions of your rc script (root:wheel, mode 555).

I would then check to see if service spawn-fcgi-rt start works as expected.

Then, as suggested by Tierks, start tracing the execution of the rc scripts of interest (those that should run both before and after yours).
 
Sorry, I should have taken a closer look at your original post.

I would check ownership and permissions of your rc script (root:wheel, mode 555).

I would then check to see if service spawn-fcgi-rt start works as expected.

Then, as suggested by Tierks, start tracing the execution of the rc scripts of interest (those that should run both before and after yours).
Thanks. I before I had a chance to try that, I discovered some documentation for another Perl-based program which had some configuration for spawn-fcgi. I adapted that for RT. In case someone else stumbles upon this thread in the future, the following is my working solution:

Add the following to /etc/rc.conf:

Code:
spawn_fcgi_enable="YES"
spawn_fcgi_app="/usr/local/bin/perl"
spawn_fcgi_app_args="/opt/rt5/sbin/rt-server.fcgi"
spawn_fcgi_bindsocket="/var/run/rt/rt-fcgi.sock"
spawn_fcgi_bindsocket_mode="0600 -U www"
spawn_fcgi_username="www"
spawn_fcgi_groupname="www"

Code:
sudo chown www:www /var/run/rt

Update REQUIRE for spawn-fcgi so it loads after nginx and mysql:
Code:
sudo nano /usr/local/etc/rc.d/spawn-fcgi
# REQUIRE: DAEMON mysql nginx
 
Back
Top