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.
See also
See also
Check if a service is running.
import fabtools
if fabtools.service.is_running('foo'):
print "Service foo is running!"
Start a service.
import fabtools
# Start service if it is not running
if not fabtools.service.is_running('foo'):
fabtools.service.start('foo')
Stop a service.
import fabtools
# Stop service if it is running
if fabtools.service.is_running('foo'):
fabtools.service.stop('foo')
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')