diff --git a/README.md b/README.md index 588a179..d415b33 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,10 @@ redhat init.d or upstart depending on the service provider. The location of the uwsgi config file. Default: '/etc/uwsgi.ini' +* `log_dir` + The location of the uwsgi emperor log. + Default: '/var/log/uwsgi/uwsgi-emperor.log' + * `app_directory` Vassal directory for application config files. diff --git a/manifests/init.pp b/manifests/init.pp index d8935ed..0c14b18 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -49,6 +49,10 @@ # [*config_file*] # The location of the uwsgi config file. Default: '/etc/uwsgi.ini' # +# [*log_file*] +# The location of the uwsgi emperor log. +# Default: '/var/log/uwsgi/uwsgi-emperor.log' +# # [*app_directory*] # Vassal directory for application config files # @@ -88,6 +92,7 @@ $service_provider = $uwsgi::params::service_provider, $manage_service_file = $uwsgi::params::manage_service_file, $config_file = $uwsgi::params::config_file, + $log_file = $uwsgi::params::log_file, $app_directory = $uwsgi::params::app_directory, $install_pip = $uwsgi::params::install_pip, $install_python_dev = $uwsgi::params::install_python_dev, diff --git a/manifests/params.pp b/manifests/params.pp index 796e64f..33f4ffd 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -17,6 +17,7 @@ $config_file = '/etc/uwsgi.ini' $install_pip = true $install_python_dev = true + $log_file = '/var/log/uwsgi/uwsgi-emperor.log' $python_pip = 'python-pip' case $::osfamily { diff --git a/templates/uwsgi.ini.erb b/templates/uwsgi.ini.erb index 1bffb7e..15572b2 100644 --- a/templates/uwsgi.ini.erb +++ b/templates/uwsgi.ini.erb @@ -11,7 +11,7 @@ emperor-tyrant = true master = true autoload = true log-date = true -logto = /var/log/uwsgi/uwsgi-emperor.log +logto = <%= @log_file %> <% if @emperor_options @emperor_options.sort.each do |key, value| diff --git a/templates/uwsgi_service-redhat.erb b/templates/uwsgi_service-redhat.erb index 4c49476..9fe8f7b 100644 --- a/templates/uwsgi_service-redhat.erb +++ b/templates/uwsgi_service-redhat.erb @@ -18,15 +18,23 @@ # Source function library. . /etc/rc.d/init.d/functions -OPTIONS="--daemonize --die-on-term --ini <%= @config_file %>" +UWSGILOG="<%= @log_file %>" UWSGIPID="<%= @pidfile %>" UWSGISOCKET="<%= @socket %>" +OPTIONS="--daemonize "${UWSGILOG}" --die-on-term --ini <%= @config_file %>" + +UWSGILOGDIR="${UWSGILOG%/*}" UWSGIPIDDIR="${UWSGIPID%/*}" UWSGISOCKETDIR="${UWSGISOCKET%/*}" [ -f /etc/sysconfig/uwsgi ] && . /etc/sysconfig/uwsgi +if [ ! -d "${UWSGILOGDIR}" ]; then + mkdir -p "${UWSGILOGDIR}" + [ -n "${RUNAS}" ] && chown "${RUNAS}:" "${UWSGILOGDIR}" +fi + if [ ! -d "${UWSGIPIDDIR}" ]; then mkdir -p "${UWSGIPIDDIR}" [ -n "${RUNAS}" ] && chown "${RUNAS}:" "${UWSGIPIDDIR}" diff --git a/templates/uwsgi_upstart.conf.erb b/templates/uwsgi_upstart.conf.erb index 931a4e7..a65e612 100644 --- a/templates/uwsgi_upstart.conf.erb +++ b/templates/uwsgi_upstart.conf.erb @@ -10,12 +10,14 @@ stop on runlevel [!2345] respawn pre-start script + uwsgilog="<%= @log_file %>" uwsgipid="<%= @pidfile %>" uwsgisocket="<%= @socket %>" + uwsgilogddir="${uwsgilogd%/*}" uwsgipiddir="${uwsgipid%/*}" uwsgisocketdir="${uwsgisocket%/*}" mkdir -p "$uwsgipiddir" mkdir -p "$uwsgisocketdir" - mkdir -p /var/log/uwsgi + mkdir -p "$uwsgilogdir" end script exec uwsgi --die-on-term --ini <%= @config_file %>