Skip to content

Commit aedbf91

Browse files
committed
Set pid and socket directories based on OS
1 parent d8ab2cd commit aedbf91

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

manifests/params.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@
2222
case $::osfamily {
2323
redhat: {
2424
$app_directory = '/etc/uwsgi.d'
25+
$pidfile = '/var/run/uwsgi/uwsgi.pid'
2526
$python_dev = 'python-devel'
27+
$socket = '/var/run/uwsgi/uwsgi.socket'
2628
}
2729
default: {
2830
$app_directory = '/etc/uwsgi/apps-enabled'
31+
$pidfile = '/run/uwsgi/uwsgi.pid'
2932
$python_dev = 'python-dev'
33+
$socket = '/run/uwsgi/uwsgi.socket'
3034
}
3135
}
3236
}

templates/uwsgi.ini.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# uWSGI main process configuration
55
#
66
[uwsgi]
7-
socket = /run/uwsgi/uwsgi.socket
8-
pidfile = /run/uwsgi/uwsgi.pid
7+
socket = <%= @socket %>
8+
pidfile = <%= @pidfile %>
99
emperor = <%= @app_directory %>
1010
emperor-tyrant = true
1111
master = true

templates/uwsgi_service-redhat.erb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,24 @@
1919
. /etc/rc.d/init.d/functions
2020

2121
OPTIONS="--daemonize --die-on-term --ini <%= @config_file %>"
22+
UWSGIPID="<%= @pidfile %>"
23+
UWSGISOCKET="<%= @socket %>"
24+
25+
UWSGIPIDDIR="${UWSGIPID%/*}"
26+
UWSGISOCKETDIR="${UWSGISOCKET%/*}"
2227

2328
[ -f /etc/sysconfig/uwsgi ] && . /etc/sysconfig/uwsgi
2429

30+
if [ ! -d "${UWSGIPIDDIR}" ]; then
31+
mkdir -p "${UWSGIPIDDIR}"
32+
[ -n "${RUNAS}" ] && chown "${RUNAS}:" "${UWSGIPIDDIR}"
33+
fi
34+
35+
if [ ! -d "${UWSGISOCKETDIR}" ]; then
36+
mkdir -p "${UWSGISOCKETDIR}"
37+
[ -n "${RUNAS}" ] && chown "${RUNAS}:" "${UWSGISOCKETDIR}"
38+
fi
39+
2540
RETVAL=0
2641
prog=uwsgi
2742
lockfile=/var/lock/subsys/$prog

0 commit comments

Comments
 (0)