示例#1
0
def stop(ctx, **kwargs):
    pid = ctx.instance.runtime_properties.get('pid')
    if pid is None:
        ctx.logger.warning("No PID set; skipping")
        return

    try:
        run_subprocess(ctx, ['sudo', 'kill', '-9', str(pid)])
    except Exception as ex:
        _, _, tb = sys.exc_info()
        if isinstance(ex, OSError) and ex.errno == errno.ESRCH:
            ctx.logger.warning("No PID {0} found".format(pid))
        else:
            ctx.logger.exception("Failed terminating server")

    ctx.instance.runtime_properties.pop('pid')
def configure(ctx, configuration, **kwargs):
    with tempfile.NamedTemporaryFile(delete=False) as config_file:
        config_file.write('\n'.join({
            "{}={}".format(key, value)
            for key, value in configuration.items()
        }))
        config_file.close()

    run_subprocess(ctx, args=['sudo', 'mv', config_file.name, CONFIG_FILE])
    run_subprocess(ctx, args=['sudo', 'chown', 'root:root', CONFIG_FILE])
    run_subprocess(ctx, args=['sudo', 'systemctl', 'enable', SERVICE_NAME])
def delete(ctx, **kwargs):
    run_subprocess(ctx, args=['sudo', 'systemctl', 'disable', SERVICE_NAME])
def stop(ctx, **kwargs):
    run_subprocess(ctx, args=['sudo', 'systemctl', 'stop', SERVICE_NAME])
def create(ctx, **kwargs):
    run_subprocess(ctx, args=['sudo', 'yum', '-y', 'install', 'vsftpd'])
示例#6
0
def create(ctx, npm_list, **kwargs):
    run_subprocess(ctx, args=['sudo', 'yum', '-y', 'install', 'nodejs'])

    for npm in npm_list:
        run_subprocess(ctx, args=['sudo', 'npm', 'install', npm, '-g'])