Skip to content

Commit a26247f

Browse files
committed
Make log file a parameter so it can be set in various init/config scripts
1 parent 8dd09f4 commit a26247f

5 files changed

Lines changed: 19 additions & 3 deletions

File tree

manifests/init.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
# [*config_file*]
5050
# The location of the uwsgi config file. Default: '/etc/uwsgi.ini'
5151
#
52+
# [*log_file*]
53+
# The location of the uwsgi emperor log.
54+
# Default: '/var/log/uwsgi/uwsgi-emperor.log'
55+
#
5256
# [*app_directory*]
5357
# Vassal directory for application config files
5458
#
@@ -88,6 +92,7 @@
8892
$service_provider = $uwsgi::params::service_provider,
8993
$manage_service_file = $uwsgi::params::manage_service_file,
9094
$config_file = $uwsgi::params::config_file,
95+
$log_file = $uwsgi::params::log_file,
9196
$app_directory = $uwsgi::params::app_directory,
9297
$install_pip = $uwsgi::params::install_pip,
9398
$install_python_dev = $uwsgi::params::install_python_dev,

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
$config_file = '/etc/uwsgi.ini'
1818
$install_pip = true
1919
$install_python_dev = true
20+
$log_file = '/var/log/uwsgi/uwsgi-emperor.log'
2021
$python_pip = 'python-pip'
2122

2223
case $::osfamily {

templates/uwsgi.ini.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ emperor-tyrant = true
1111
master = true
1212
autoload = true
1313
log-date = true
14-
logto = /var/log/uwsgi/uwsgi-emperor.log
14+
logto = <%= @log_file %>
1515
<%
1616
if @emperor_options
1717
@emperor_options.sort.each do |key, value|

templates/uwsgi_service-redhat.erb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,23 @@
1818
# Source function library.
1919
. /etc/rc.d/init.d/functions
2020

21-
OPTIONS="--daemonize --die-on-term --ini <%= @config_file %>"
21+
UWSGILOG="<%= @log_file %>"
2222
UWSGIPID="<%= @pidfile %>"
2323
UWSGISOCKET="<%= @socket %>"
2424

25+
OPTIONS="--daemonize "${UWSGILOG}" --die-on-term --ini <%= @config_file %>"
26+
27+
UWSGILOGDIR="${UWSGILOG%/*}"
2528
UWSGIPIDDIR="${UWSGIPID%/*}"
2629
UWSGISOCKETDIR="${UWSGISOCKET%/*}"
2730

2831
[ -f /etc/sysconfig/uwsgi ] && . /etc/sysconfig/uwsgi
2932

33+
if [ ! -d "${UWSGILOGDIR}" ]; then
34+
mkdir -p "${UWSGILOGDIR}"
35+
[ -n "${RUNAS}" ] && chown "${RUNAS}:" "${UWSGILOGDIR}"
36+
fi
37+
3038
if [ ! -d "${UWSGIPIDDIR}" ]; then
3139
mkdir -p "${UWSGIPIDDIR}"
3240
[ -n "${RUNAS}" ] && chown "${RUNAS}:" "${UWSGIPIDDIR}"

templates/uwsgi_upstart.conf.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ stop on runlevel [!2345]
1010
respawn
1111

1212
pre-start script
13+
uwsgilog="<%= @log_file %>"
1314
uwsgipid="<%= @pidfile %>"
1415
uwsgisocket="<%= @socket %>"
16+
uwsgilogddir="${uwsgilogd%/*}"
1517
uwsgipiddir="${uwsgipid%/*}"
1618
uwsgisocketdir="${uwsgisocket%/*}"
1719
mkdir -p "$uwsgipiddir"
1820
mkdir -p "$uwsgisocketdir"
19-
mkdir -p /var/log/uwsgi
21+
mkdir -p "$uwsgilogdir"
2022
end script
2123
exec uwsgi --die-on-term --ini <%= @config_file %>

0 commit comments

Comments
 (0)