I am trying to adapt the script found here to my purposes:
www.nginx.com
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):
My /etc/rc.conf:
My script /usr/local/etc/rc.d/spawn-fcgi-rt:
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?
FreeBSD Spawn FCGI Init Script | NGINX
A "one size fits all" script to interface with spawn-fcgi in a friendly way.
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?