Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # PROVIDE: uwsgiini
- # REQUIRE: DAEMON
- # KEYWORD: shutdown
- #
- # Add the following lines to /etc/rc.conf to enable uwsgi:
- #
- # uwsgiini_enable (bool): Set it to "YES" to enable uwsgi
- # Default is "NO".
- #
- # If you would like to have multiple uWSGI instances running, you can
- # define multiple profiles:
- #
- # uwsgiini_profiles (str): Set the list of uwsgi profiles
- # Default is "".
- #
- # For each profile you can then define different options (except for
- # uwsgiini_enable) using the syntax uwsgi_<profile>_<option>
- . /etc/rc.subr
- name="uwsgiini"
- rcvar=uwsgiini_enable
- load_rc_config $name
- command=/usr/local/bin/uwsgi
- : ${uwsgiini_enable="NO"}
- : ${uwsgiini_apps=""}
- : ${uwsgi_socket="/tmp/${name}.sock"}
- : ${uwsgi_logfile="/var/log/${name}.log"}
- : ${uwsgi_pidfile="/var/run/${name}.pid"}
- is_uwsgi_app() {
- local app
- for app in $uwsgiini_apps; do
- if [ "$app" = "$1" ]; then
- return 0
- fi
- done
- return 1
- }
- if [ -n "${uwsgiini_apps}" ]; then
- if [ -n "$2" ]; then
- app="$2"
- if ! is_uwsgi_app $app; then
- echo "$app: no such app defined in uwsgiini_apps."
- exit 1
- fi
- eval uwsgiini_socket=\${uwsgiini_${app}_socket:-"/var/run/uwsgi/${app}/${app}.sock"}
- eval uwsgiini_pidfile=\${uwsgiini_${app}_pidfile:-"/var/run/uwsgi/${app}/${app}.pid"}
- eval uwsgiini_logfile=\${uwsgiini_${app}_logfile:-"/var/log/uwsgi/${app}.log"}
- elif [ -n "$1" ]; then
- for app in ${uwsgiini_apps}; do
- echo "Processing ${name} app: ${app}"
- /usr/local/etc/rc.d/uwsgiini $1 ${app}
- done
- exit 0
- fi
- fi
- command=/usr/local/bin/uwsgi
- command_args="--ini /usr/local/etc/uwsgi.ini:${app} --daemonize ${uwsgiini_logfile} --pidfile ${uwsgiini_pidfile}"
- pidfile=${uwsgiini_pidfile}
- stop_postcmd=stop_postcmd
- reload_precmd=reload_precmd
- brutalreload_cmd=brutalreload_cmd
- sig_stop="INT"
- extra_commands="reload brutalreload"
- procname=${uwsgiini_procname}
- stop_postcmd()
- {
- rm -f ${uwsgiini_pidfile} # ${uwsgiini_socket}
- }
- reload_precmd()
- {
- echo "Gracefully reloading ${name} without closing the main sockets."
- }
- brutalreload_cmd()
- {
- echo "Reloading ${name} without closing the main sockets."
- reload_precmd=""
- sig_reload="TERM"
- run_rc_command ${rc_prefix}reload $rc_extra_args || return 1
- }
- run_rc_command "$1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement