# @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.py": content => epp("${module_name}/gunicorn.conf.py.epp", $options), notify => Service["gunicorn@${instance_name}"], } service { "gunicorn@${instance_name}": ensure => running, enable => true, } }