Defined Type: uwsgi::app

Defined in:
modules/uwsgi/manifests/app.pp

Summary

Provisions a uWSGI application server instance.

Overview

SPDX-License-Identifier: Apache-2.0

Examples:

uwsgi::app { 'graphite-web':
  settings => {
    uwsgi => {
        'plugins'     => 'python',
        'socket'      => '/var/run/graphite-web/graphite-web.sock',
        'wsgi-file'   => '/usr/share/graphite-web/graphite.wsgi',
        'master'      => true,
        'processes'   => 4,
        'env'         => ['MYSQL_HOST=localhost', 'STATSD_PREFIX=wat'],
    },
  },
}

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: present)

    tne ensurable parameter

  • enabled (Boolean) (defaults to: true)

    if the service should be enabled

  • service_settings (String) (defaults to: '--die-on-term')

    Additional arguments to pass to uwsgi

  • settings (Hash) (defaults to: {})

    Hash of hashes, representing the app configuration. Each key of the top-level hash is used as a section in the app's ini file. If a second level key has a value that is an Array, that key is repeated for each value of the array

  • core_limit (String) (defaults to: '0')

    A string containing the core size limit to allow coredumps. Values: 'unlimited', 'nG' (n is a number of Gigabytes), or '0' for no core.

  • routes (Array[Uwsgi::Route]) (defaults to: [])

    a list of additional routes to configure

  • systemd_user (String[1]) (defaults to: 'www-data')

    the user the syetmd unit will be started with

  • systemd_group (String[1]) (defaults to: 'www-data')

    the group the syetmd unit will be started with

  • extra_systemd_opts (Hash) (defaults to: {})

    A hash of addtional options for the systemd unit

  • monitoring (Wmflib::Ensure) (defaults to: present)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'modules/uwsgi/manifests/app.pp', line 32

define uwsgi::app(
    Wmflib::Ensure      $ensure             = present,
    Boolean             $enabled            = true,
    String              $service_settings   = '--die-on-term',
    String              $core_limit         = '0',
    Hash                $settings           = {},
    Array[Uwsgi::Route] $routes             = [],
    String[1]           $systemd_user       = 'www-data',
    String[1]           $systemd_group      = 'www-data',
    Hash                $extra_systemd_opts = {},
    Wmflib::Ensure      $monitoring         = present,
) {
    include uwsgi

    $basename = regsubst($title, '\W', '-', 'G')

    file { "/etc/uwsgi/apps-available/${basename}.ini":
        ensure  => $ensure,
        content => template('uwsgi/app.ini.erb'),
    }

    $inipath =  "/etc/uwsgi/apps-enabled/${basename}.ini"
    if $ensure == 'present' and $enabled {
        file { $inipath:
            ensure => link,
            target => "/etc/uwsgi/apps-available/${basename}.ini",
        }

        base::service_unit { "uwsgi-${title}":
            ensure    => present,
            systemd   => systemd_template('uwsgi'),
            subscribe => File["/etc/uwsgi/apps-available/${basename}.ini"],
        }

        nrpe::monitor_service { "uwsgi-${title}":
            ensure       => $monitoring,
            description  => "${title} uWSGI web app",
            nrpe_command => "/bin/systemctl status uwsgi-${title}",
            require      => Base::Service_unit["uwsgi-${title}"],
            notes_url    => "https://wikitech.wikimedia.org/wiki/Monitoring/Services/${title}",
        }
    } else {
        file { $inipath:
            ensure => absent,
        }

        base::service_unit { "uwsgi-${title}": # lint:ignore:wmf_styleguide
            ensure => absent,
        }

        nrpe::monitor_service { "uwsgi-${title}":
            ensure => absent,
        }
    }
}