Skip to content

Instantly share code, notes, and snippets.

@jjuarez
Created May 19, 2010 22:01
Show Gist options
  • Select an option

  • Save jjuarez/406898 to your computer and use it in GitHub Desktop.

Select an option

Save jjuarez/406898 to your computer and use it in GitHub Desktop.
nginx service script
#!/bin/sh
NGINX_BASE_DIR="/opt/nginx"
NGINX_DAEMON="${NGINX_BASE_DIR}/sbin/nginx"
NGINX_CONF="${NGINX_BASE_DIR}/conf/nginx.conf"
__launch_signal( ) {
${NGINX_DAEMON} -s ${1} &>/dev/null
}
__checkconfig( ) {
${NGINX_DAEMON} -c ${NGINX_CONF} -t &>/dev/null
}
__start( ) {
[ -r ${NGINX_CONF} ] || exit 1
__checkconfig && ${NGINX_DAEMON} -c ${NGINX_CONF} &>/dev/null || return ${?}
}
__stop( ) {
__launch_signal stop
}
__reload( ) {
__checkconfig && __launch_signar reload || return ${?}
}
__restart( ) {
__stop && __start
}
__show_usage( ) {
echo "Usage: ${0} {start|stop|restart|reload}"
exit 3
}
##
# :: main ::
case "${1}" in
start|stop|restart|reload)
[ -x ${NGINX_DAEMON} ] || exit 2
__${1}
;;
*)
__show_usage
;;
esac
@jjuarez
Copy link
Author

jjuarez commented May 19, 2010

A simple ctl script for nginx platform agnostic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment