예제 #1
0
    def supervisordconf():
        ctx = DeployContext()

        includes = []

        daemons_conf_dir = ROOT.joinpath('etc/supervisord/daemons/')
        daemons_conf_dir.makedirs_p()

        for daemon in daemons:
            daemon_conf = daemons_conf_dir.joinpath(daemon.name + '.conf')
            includes.append(daemon_conf)

            info('Writing daemon %s', daemon)
            write_config(daemon_conf, {
                'program:{}'.format(daemon.name): {
                    'command': daemon.command,
                    'environment': ','.join('{}="{}"'.format(key, val) for key, val in daemon.environ.items())
                },
            })

        groups_conf_dir = ROOT.joinpath('etc/supervisord/groups/')
        groups_conf_dir.makedirs_p()

        for group in daemons.groups():
            group_conf = groups_conf_dir.joinpath(group.name + '.conf')
            includes.append(group_conf)

            info('Writing group %s', group)
            write_config(group_conf, {
                'group:{}'.format(group.name): {
                    'programs': ','.join(d.name for d in group),
                }
            })

        supervisorctl_conf = ROOT.joinpath('etc/supervisord/supervisorctl.conf')
        write_config(supervisorctl_conf, {
            'supervisorctl': {
                'serverurl': 'unix://' + SOCKET,
            },
        })

        supervisord_conf = ROOT.joinpath(defaults.SUPERVISORDCONF)
        write_config(supervisord_conf, {
            'rpcinterface:supervisor': {
                'supervisor.rpcinterface_factory': 'supervisor.rpcinterface:make_main_rpcinterface',
            },
            'unix_http_server': {
                'file': SOCKET,
                'chown': '{UID}:{GID}'.format(**ctx),
            },
            'supervisord': {
                'logfile': LOGS.joinpath('supervisord.log'),
                'pidfile': PIDFILE,
            },
            'include': {
                'files': ' '.join(includes),
            }
        })
예제 #2
0
파일: uwsgi.py 프로젝트: cecedille1/Sett
def uwsgi_conf():
    """
    Generates parts/uwsgi/uwsgi.xml
    """
    context = DeployContext({
        'uwsgi': {
            'processes': 1,
        },
        'env': [],
        'locations': {},
        'directories': {},
        'pythonpath': ROOT,
    })

    module, name = context['wsgi_application'].rsplit('.', 1)
    config = {
        'module': '{}:{}'.format(module, name),
        'logto': LOGS.joinpath('uwsgi.log'),
        'processes': context['uwsgi.processes'],
        'home': VENV_DIR,
        'env': context['env'],
        'pythonpath': context['pythonpath'],
    }

    if 'uwsgi.socket' in context:
        config.update({
            'socket': context['uwsgi.socket'],
            'chown-socket': '{UID}:{GID}'.format(**context),
            'chmod-socket': '660',
        })
    else:
        config.update({
            'http': context['uwsgi.http'],
        })

    if defaults.STATIC_SERVER == 'uwsgi':
        config['static-map'] = [
            '{}={}'.format(context['locations'][key],
                           context['directories'][key])
            for key in context['locations']
        ]

    config.update(defaults.UWSGI_EXTRA)
    ouput_writer = get_uwsgi_output()
    ouput_writer.write(config)
예제 #3
0
파일: uwsgi.py 프로젝트: cecedille1/Sett
def log_dir():
    """Ensure that the log directory exists"""
    if not LOGS.exists():
        LOGS.makedirs()