fabtools.service

System services

This module provides low-level tools for managing system services, using the service command. It supports both upstart services and traditional SysV-style /etc/init.d/ scripts.

fabtools.service.is_running(service)[source]

Check if a service is running.

import fabtools

if fabtools.service.is_running('foo'):
    print "Service foo is running!"
fabtools.service.start(service)[source]

Start a service.

import fabtools

# Start service if it is not running
if not fabtools.service.is_running('foo'):
    fabtools.service.start('foo')
fabtools.service.stop(service)[source]

Stop a service.

import fabtools

# Stop service if it is running
if fabtools.service.is_running('foo'):
    fabtools.service.stop('foo')
fabtools.service.restart(service)[source]

Restart a service.

import fabtools

# Start service, or restart it if it is already running
if fabtools.service.is_running('foo'):
    fabtools.service.restart('foo')
else:
    fabtools.service.start('foo')
fabtools.service.reload(service)[source]

Reload a service.

import fabtools

# Reload service
fabtools.service.reload('foo')

Warning

The service needs to support the reload operation.

fabtools.service.force_reload(service)[source]

Force reload a service.

import fabtools

# Force reload service
fabtools.service.force_reload('foo')

Warning

The service needs to support the force-reload operation.

Project Versions

Table Of Contents

Previous topic

fabtools.rpm

Next topic

fabtools.shorewall

This Page