1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# @summary Sets up a single gunicorn instance
#
# @param app
# Name of the app, probably something like "wsgi_module:app"
# @param address
# Address to bind Gunicorn to
# @param instance_name
# Name for this instance
# @param workers
# Workers used by this gunicorn instance. `$cpu_count * 2 + 1` is
# copied from the Gunicorn manual.
# @param user
# User to run this instance as.
# @param group
# Group to run this instance as.
define gunicorn::instance (
String $app,
String $address,
String $instance_name = $name,
Integer $workers = $facts['processors']['count'] * 2 + 1,
Variant[String, Integer] $user = $gunicorn::setup::user,
Variant[String, Integer] $group = $gunicorn::setup::group,
) {
require gunicorn::setup
$options = {
'address' => $address,
'proc_name' => $instance_name,
'workers' => $workers,
'wsgi_app' => $app,
'user' => $user,
'group' => $group,
}
file { "${gunicorn::setup::instance_dir}/${instance_name}.conf.pp":
content => epp("${module_name}/gunicorn.conf.py.epp", $options),
}
service { "gunicorn@${instance_name}":
ensure => running,
enable => true,
}
}
|