class genvid.toolbox.LocalService(services_dir='local-services', **kwargs)

Bases: genvid.toolbox.service.ServiceTool

This class wraps a service to be run locally as a background process.

The service configuration is stored under ROOTDIR/local-services/<name> with a config directory and a data directory. The service starts as a background process with its output redirected to <name>.stdout.log and <name>.stderr.log. The service saves its process ID under <name>.pid.

basedir = None

Base directory to install the service.

configdir = None

Configuration directory for the service.

datadir = None

Data directory for the service.

logdir = None

Log directory for the service.

backupdir = None

Backup directory for the service.


Configuration file of the service.

pidfile = None

PID file of the service instance.

logout = None

Standard Output log file of the service.

options = None

Options file for the service.

This file keeps the list of options passed to the install command.


Returns if the service is installed.

install(reconfigure=False, **options)

Install the service if not already installed.

This checks for the service configuration, but doesn’t start the service.

uninstall(clean: bool = False)

Uninstall the service.


Return a psutil.Process of the service or None if none is found.

This loads the PID from the pidfile. It doesn’t check if the process is the right one and so can be fooled in case of PID wraparound.


Check if the service is running.

This checks the state of the process identified by the pidfile.

print_log(lines: typing.Union[int, NoneType] = None)

Print the log file for this service.

Changed in version 1.27.0: Removed stdout boolean flag as both logerr and logout are now written to them same folder.

The value for lines is either the number of lines from the last to print or None.


Starts the service if it’s not already started.

Changed in version 1.29.0: Add check for other running instances of the same service.


Stop the service if it’s running.

status(withlog=False, lines=None)

Return the status of the service.

This checks the state of the process identified by the PID file.