Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Options #11

Merged
merged 2 commits into from
Apr 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,31 @@ uwsgi::app:
module: 'mysite.wsgi:application'
socket: '/tmp/uwsgi_django2.sock'
```

Example using hiera to use Debian Jessie APT packages & default file locations

```yaml
---
classes:
- uwsgi
uwsgi::package_name:
- 'uwsgi-emperor'
- 'uwsgi-plugins-all'
uwsgi::package_provider: 'apt'
uwsgi::service_name: 'uwsgi-emperor'
uwsgi::service_provider: 'debian'
uwsgi::manage_service_file: false
uwsgi::config_file: '/etc/uwsgi-emperor/emperor.ini'
uwsgi::log_dir: '/var/log/uwsgi/emperor.log'
uwsgi::app_directory: '/etc/uwsgi-emperor/vassals'
uwsgi::install_pip: false
uwsgi::install_python_dev: false
uwsgi::socket: undef
uwsgi::pidfile: '/run/uwsgi-emperor.pid'
uwsgi::emperor_options:
uid: 'www-data'
gid: 'www-data'
workers: '2'
no-orphans: 'true'
```

3 changes: 1 addition & 2 deletions manifests/app.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
group => $gid,
mode => '0644',
content => template($template),
require => Package[$::uwsgi::package_name],
notify => Service[$::uwsgi::service_name]
require => Package[$::uwsgi::package_name]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this notify not required? Is the directory monitored by the running service?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct. UWSGI in Emperor mode detects the modify time of the
vassals and reloads them automatically.

http://uwsgi-docs.readthedocs.org/en/latest/Emperor.html

On Sun, Apr 12, 2015 at 11:30 PM, Josh Smeaton notifications@github.com
wrote:

In manifests/app.pp
#11 (comment):

@@ -44,7 +44,6 @@
group => $gid,
mode => '0644',
content => template($template),

  •    require => Package[$::uwsgi::package_name],
    
  •    notify  => Service[$::uwsgi::service_name]
    

Is this notify not required? Is the directory monitored by the running
service?


Reply to this email directly or view it on GitHub
https://github.com/Engage/puppet-uwsgi/pull/11/files#r28213853.

}
85 changes: 44 additions & 41 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
$install_python_dev = $uwsgi::params::install_python_dev,
$python_pip = $uwsgi::params::python_pip,
$python_dev = $uwsgi::params::python_dev,
$pidfile = $uwsgi::params::pidfile,
$socket = $uwsgi::params::socket,
$emperor_options = undef
) inherits uwsgi::params {

Expand Down Expand Up @@ -136,44 +138,49 @@
require => Package[$package_name]
}

if $service_file == undef {
$service_file_real = $service_provider ? {
redhat => '/etc/init.d/uwsgi',
upstart => '/etc/init/uwsgi.conf',
default => '/etc/init/uwsgi.conf',
}
} else {
$service_file_real = $service_file
}
if $manage_service_file == true {
if $service_file == undef {
$service_file_real = $service_provider ? {
redhat => '/etc/init.d/uwsgi',
upstart => '/etc/init/uwsgi.conf',
default => '/etc/init/uwsgi.conf',
}
} else {
$service_file_real = $service_file
}

if $service_file_mode == undef {
$service_file_mode_real = $service_provider ? {
redhat => '0555',
upstart => '0644',
default => '0644',
}
} else {
$service_file_mode_real = $service_file_mode
}
if $service_file_mode == undef {
$service_file_mode_real = $service_provider ? {
redhat => '0555',
upstart => '0644',
default => '0644',
}
} else {
$service_file_mode_real = $service_file_mode
}

if $service_template == undef {
$service_template_real = $service_provider ? {
redhat => 'uwsgi/uwsgi_service-redhat.erb',
upstart => 'uwsgi/uwsgi_upstart.conf.erb',
default => 'uwsgi/uwsgi_upstart.conf.erb',
}
} else {
$service_template_real = $service_template
}
if $service_template == undef {
$service_template_real = $service_provider ? {
redhat => 'uwsgi/uwsgi_service-redhat.erb',
upstart => 'uwsgi/uwsgi_upstart.conf.erb',
default => 'uwsgi/uwsgi_upstart.conf.erb',
}
} else {
$service_template_real = $service_template
}

file { $service_file_real:
ensure => $file_ensure,
owner => 'root',
group => 'root',
mode => $service_file_mode_real,
replace => $manage_service_file,
content => template($service_template_real),
require => Package[$package_name]
file { $service_file_real:
ensure => $file_ensure,
owner => 'root',
group => 'root',
mode => $service_file_mode_real,
replace => $manage_service_file,
content => template($service_template_real),
require => Package[$package_name]
}
$required_files = [ $config_file, $service_file_real ]
} else {
$required_files = $config_file
}

file { $app_directory:
Expand All @@ -192,13 +199,9 @@
provider => $service_provider,
require => [
Package[$package_name],
File[$config_file],
File[$service_file_real]
File[$required_files]
],
subscribe => [
File[$config_file],
File[$service_file_real]
]
subscribe => File[$required_files]
}

# finally, configure any applications necessary
Expand Down
4 changes: 4 additions & 0 deletions templates/uwsgi.ini.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
# uWSGI main process configuration
#
[uwsgi]
<% if @socket -%>
socket = <%= @socket %>
<% end -%>
pidfile = <%= @pidfile %>
emperor = <%= @app_directory %>
emperor-tyrant = true
master = true
autoload = true
log-date = true
<% if @log_file -%>
logto = <%= @log_file %>
<% end -%>
<%
if @emperor_options
@emperor_options.sort.each do |key, value|
Expand Down