|
1 | 1 |
|
2 | 2 | define appdeploy::django (
|
3 | 3 | $user,
|
4 |
| - $ip = '127.0.0.1', |
5 |
| - $port = 8001, |
6 | 4 | $environment = undef,
|
7 | 5 | $celery = false,
|
8 | 6 | $proxy = true,
|
9 | 7 | $proxy_hosts = [],
|
10 | 8 | $directory = "/home/$user/$title/src",
|
11 |
| - $gunicorn_cfg = "$title/gunicorn.conf.py", |
12 | 9 | $vhost_cfg_append = undef,
|
| 10 | + $gunicorn = { |
| 11 | + workers => 'auto', |
| 12 | + worker_class => 'eventlet', |
| 13 | + loglevel => 'error', |
| 14 | + bind => '127.0.0.1:8001', |
| 15 | + errorlog => "~/$title.log", |
| 16 | + }, |
| 17 | + |
| 18 | + # Deprecated params |
| 19 | + $ip = undef, |
| 20 | + $port = undef, |
| 21 | + $gunicorn_cfg = undef, |
13 | 22 | ) {
|
14 | 23 | include supervisor
|
15 | 24 |
|
|
24 | 33 | environment => $environment,
|
25 | 34 | }
|
26 | 35 |
|
| 36 | + validate_hash($gunicorn) |
| 37 | + |
27 | 38 | $virtualenv_path = "/home/$user/.virtualenvs/$title"
|
28 | 39 | $manage_path = "$virtualenv_path/bin/python $directory/manage.py"
|
29 | 40 |
|
| 41 | + $default_gunicorn_cfg_path = "/etc/gunicorn-$title.conf.py" |
| 42 | + |
| 43 | + $gunicorn_cfg_path = pick($gunicorn_cfg, '/etc/gunicorn-$title.conf.py') |
| 44 | + if $gunicorn_cfg { |
| 45 | + warning('Passing "gunicorn_cfg" to appdeploy::django is deprecated; please use the gunicorn parameter instead.') |
| 46 | + $gunicorn_cfg_path = $gunicorn_cfg |
| 47 | + |
| 48 | + } else { |
| 49 | + $gunicorn_cfg_path = $default_gunicorn_cfg_path |
| 50 | + |
| 51 | + file { "$title-gunicorn-config": |
| 52 | + path => $gunicorn_cfg_path, |
| 53 | + content => template("appdeploy/django/gunicorn.conf.py.erb"), |
| 54 | + before => Supervisor::App[$title], |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + if $ip or $port { |
| 59 | + # IP and Port should be set using $gunicorn hash map |
| 60 | + warning('Passing "ip" and/or "port" to appdeploy::django is deprecated; please use gunicorn["bind"] parameter instead.') |
| 61 | + $port_ = pick($port, '8001') |
| 62 | + $ip_ = pick($ip, '127.0.0.1') |
| 63 | + $app_cmd = "$virtualenv_path/bin/gunicorn $title.wsgi:application --bind=$ip_:$port_ --config=$gunicorn_cfg_path" |
| 64 | + } else { |
| 65 | + $app_cmd = "$virtualenv_path/bin/gunicorn $title.wsgi:application --config=$gunicorn_cfg_path" |
| 66 | + } |
| 67 | + |
30 | 68 | supervisor::app { $title:
|
31 |
| - command => "$virtualenv_path/bin/gunicorn $title.wsgi:application --bind=$ip:$port --config=$gunicorn_cfg", |
| 69 | + command => $app_cmd, |
32 | 70 | }
|
33 | 71 |
|
34 | 72 | if $celery {
|
|
0 commit comments