Changeset View
Changeset View
Standalone View
Standalone View
head/www/uwsgi/files/uwsgi.in
#!/bin/sh | #!/bin/sh | ||||
# | # | ||||
# $FreeBSD$ | # $FreeBSD$ | ||||
# | # | ||||
# PROVIDE: uwsgi | # PROVIDE: uwsgi | ||||
# REQUIRE: DAEMON | # REQUIRE: DAEMON | ||||
# KEYWORD: shutdown | # KEYWORD: shutdown | ||||
# | # | ||||
# Add the following lines to /etc/rc.conf to enable uwsgi: | # Add the following lines to /etc/rc.conf to enable uwsgi: | ||||
# | # | ||||
# uwsgi_enable (bool): Set it to "YES" to enable uwsgi | # uwsgi_enable (bool): Set it to "YES" to enable uwsgi | ||||
# Default is "NO". | # Default is "NO". | ||||
# uwsgi_socket (path/str): Set the path to the uwsgi unix socket | # uwsgi_socket (path/str): Set the path to the uwsgi unix socket | ||||
# Default is /tmp/uwsgi.sock. | # Default is /tmp/uwsgi.sock. | ||||
# uwsgi_socket_mode (int): Set the mode of the socket. | # uwsgi_socket_mode (int): Set the mode of the socket. | ||||
# Default is 600. | # Default is 600. | ||||
# uwsgi_socket_owner (str): Set the owner of the socket. | |||||
# Default is www:www. | |||||
# uwsgi_logfile (path): Set the path to the uwsgi log file | # uwsgi_logfile (path): Set the path to the uwsgi log file | ||||
# Default is /var/log/uwsgi.log. | # Default is /var/log/uwsgi.log. | ||||
# uwsgi_pidfile (path): Set the path to the uwsgi pid file | # uwsgi_pidfile (path): Set the path to the uwsgi pid file | ||||
# Default is /var/run/uwsgi.pid. | # Default is /var/run/uwsgi.pid. | ||||
# uwsgi_uid (int): Set the UID of the process to run with | # uwsgi_uid (int): Set the UID of the process to run with | ||||
# Default is 80. | # Default is 165 (uwsgi). | ||||
# uwsgi_gid (int): Set the GID of the process to run with | # uwsgi_gid (int): Set the GID of the process to run with | ||||
# Default is 80. | # Default is 165 (uwsgi). | ||||
# uwsgi_flags (str): Set the uwsgi command line arguments | # uwsgi_flags (str): Set the uwsgi command line arguments | ||||
# Default is "-M -L". | # Default is "-M -L". | ||||
# uwsgi_procname (str): Define to "uWSGI" if you start uwsgi with | # uwsgi_procname (str): Define to "uWSGI" if you start uwsgi with | ||||
# --auto-procname option. | # --auto-procname option. | ||||
# | # | ||||
# If you would like to have multiple uWSGI instances running, you can | # If you would like to have multiple uWSGI instances running, you can | ||||
# define multiple profiles: | # define multiple profiles: | ||||
# | # | ||||
Show All 9 Lines | |||||
rcvar=uwsgi_enable | rcvar=uwsgi_enable | ||||
load_rc_config $name | load_rc_config $name | ||||
command=%%PREFIX%%/bin/uwsgi | command=%%PREFIX%%/bin/uwsgi | ||||
: ${uwsgi_enable="NO"} | : ${uwsgi_enable="NO"} | ||||
: ${uwsgi_profiles=""} | : ${uwsgi_profiles=""} | ||||
: ${uwsgi_socket="/tmp/${name}.sock"} | : ${uwsgi_socket="/tmp/${name}.sock"} | ||||
: ${uwsgi_socket_mode="600"} | : ${uwsgi_socket_mode="660"} | ||||
: ${uwsgi_socket_owner="www:www"} | |||||
: ${uwsgi_logfile="/var/log/${name}.log"} | : ${uwsgi_logfile="/var/log/${name}.log"} | ||||
: ${uwsgi_pidfile="/var/run/${name}.pid"} | : ${uwsgi_pidfile="/var/run/${name}.pid"} | ||||
: ${uwsgi_uid="80"} | : ${uwsgi_uid="165"} | ||||
: ${uwsgi_gid="80"} | : ${uwsgi_gid="165"} | ||||
: ${uwsgi_flags="-M -L"} | : ${uwsgi_flags="-M -L"} | ||||
: ${uwsgi_procname="${command}"} | : ${uwsgi_procname="${command}"} | ||||
is_uwsgi_profile() { | is_uwsgi_profile() { | ||||
local profile | local profile | ||||
for profile in $uwsgi_profiles; do | for profile in $uwsgi_profiles; do | ||||
if [ "$profile" = "$1" ]; then | if [ "$profile" = "$1" ]; then | ||||
return 0 | return 0 | ||||
fi | fi | ||||
done | done | ||||
return 1 | return 1 | ||||
} | } | ||||
if [ -n "${uwsgi_profiles}" ]; then | if [ -n "${uwsgi_profiles}" ]; then | ||||
if [ -n "$2" ]; then | if [ -n "$2" ]; then | ||||
profile="$2" | profile="$2" | ||||
if ! is_uwsgi_profile $profile; then | if ! is_uwsgi_profile $profile; then | ||||
echo "$0: no such profile defined in uwsgi_profiles." | echo "$0: no such profile defined in uwsgi_profiles." | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
eval uwsgi_socket=\${uwsgi_${profile}_socket:-"/tmp/${name}-${profile}.sock"} | eval uwsgi_socket=\${uwsgi_${profile}_socket:-"/tmp/${name}-${profile}.sock"} | ||||
eval uwsgi_socket_mode=\${uwsgi_${profile}_socket_mode:-"600"} | eval uwsgi_socket_mode=\${uwsgi_${profile}_socket_mode:-"660"} | ||||
eval uwsgi_socket_owner=\${uwsgi_${profile}_socket_owner:-"www:www"} | |||||
eval uwsgi_logfile=\${uwsgi_${profile}_logfile:-"/var/log/${name}-${profile}.log"} | eval uwsgi_logfile=\${uwsgi_${profile}_logfile:-"/var/log/${name}-${profile}.log"} | ||||
eval uwsgi_pidfile=\${uwsgi_${profile}_pidfile:-"/var/run/${name}-${profile}.pid"} | eval uwsgi_pidfile=\${uwsgi_${profile}_pidfile:-"/var/run/${name}-${profile}.pid"} | ||||
eval uwsgi_uid=\${uwsgi_${profile}_uid:-"${uwsgi_uid}"} | eval uwsgi_uid=\${uwsgi_${profile}_uid:-"${uwsgi_uid}"} | ||||
eval uwsgi_gid=\${uwsgi_${profile}_gid:-"${uwsgi_uid}"} | eval uwsgi_gid=\${uwsgi_${profile}_gid:-"${uwsgi_uid}"} | ||||
eval uwsgi_flags=\${uwsgi_${profile}_flags:-"${uwsgi_flags}"} | eval uwsgi_flags=\${uwsgi_${profile}_flags:-"${uwsgi_flags}"} | ||||
eval uwsgi_procname=\${uwsgi_${profile}_procname:-"${uwsgi_procname}"} | eval uwsgi_procname=\${uwsgi_${profile}_procname:-"${uwsgi_procname}"} | ||||
elif [ -n "$1" ]; then | elif [ -n "$1" ]; then | ||||
for profile in ${uwsgi_profiles}; do | for profile in ${uwsgi_profiles}; do | ||||
echo "Processing ${name} profile: ${profile}" | echo "Processing ${name} profile: ${profile}" | ||||
%%PREFIX%%/etc/rc.d/uwsgi $1 ${profile} | %%PREFIX%%/etc/rc.d/uwsgi $1 ${profile} | ||||
done | done | ||||
exit 0 | exit 0 | ||||
fi | fi | ||||
fi | fi | ||||
command=%%PREFIX%%/bin/uwsgi | command=%%PREFIX%%/bin/uwsgi | ||||
command_args="--pidfile ${uwsgi_pidfile} -s ${uwsgi_socket} --chmod-socket=${uwsgi_socket_mode} -d ${uwsgi_logfile} --uid ${uwsgi_uid} --gid ${uwsgi_gid}" | command_args="--pidfile ${uwsgi_pidfile} -s ${uwsgi_socket} --chmod-socket=${uwsgi_socket_mode} --chown-socket=${uwsgi_socket_owner} -d ${uwsgi_logfile} --uid ${uwsgi_uid} --gid ${uwsgi_gid}" | ||||
pidfile=${uwsgi_pidfile} | pidfile=${uwsgi_pidfile} | ||||
stop_postcmd=stop_postcmd | stop_postcmd=stop_postcmd | ||||
reload_precmd=reload_precmd | reload_precmd=reload_precmd | ||||
brutalreload_cmd=brutalreload_cmd | brutalreload_cmd=brutalreload_cmd | ||||
sig_stop="INT" | sig_stop="INT" | ||||
extra_commands="reload brutalreload" | extra_commands="reload brutalreload" | ||||
procname=${uwsgi_procname} | procname=${uwsgi_procname} | ||||
Show All 20 Lines |