summaryrefslogtreecommitdiff
path: root/manifests/instance.pp
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-04-24 17:05:29 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-04-24 17:05:29 +0200
commit538b7ff0c8125a3f412154807e3425127968448f (patch)
treed998b3c00dc019a6ed16625b72a682c10708a5b0 /manifests/instance.pp
parentInitial commit. (diff)
downloadgunicorn-538b7ff0c8125a3f412154807e3425127968448f.tar.gz
gunicorn-538b7ff0c8125a3f412154807e3425127968448f.tar.xz
Add everything.
Diffstat (limited to 'manifests/instance.pp')
-rw-r--r--manifests/instance.pp38
1 files changed, 38 insertions, 0 deletions
diff --git a/manifests/instance.pp b/manifests/instance.pp
new file mode 100644
index 0000000..0cd72bc
--- /dev/null
+++ b/manifests/instance.pp
@@ -0,0 +1,38 @@
+# @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['processor']['count'] * 2 + 1,
+ Variant[String, Integer] $user = $gunicorn::setup::user,
+ Variant[String, Integer] $group = $gunicorn::setup::group,
+) {
+ $options = {
+ 'proc_name' => $instance_name,
+ 'wsgi_app' => $app,
+ }
+
+ file { "${gunicorn::setup::instance_dir}/${instance_name}.conf.pp":
+ content => epp("${module_name}/gunicorn.conf.py.epp", $options),
+ validate_cmd => 'gunicorn --check-config',
+ }
+
+ service { "gunicorn@${instance_name}":
+ ensure => running,
+ enable => true,
+ }
+}