class genvid.toolbox.LocalService(services_dir=None, **kwargs)

Bases: ServiceTool

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

The service configuration is stored under services_dir/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

Default value for services_dir is ~/.genvid.

Changed in version 1.39.0: Change the default value for services_dir to ~/.genvid


Base directory to install the service.


Configuration directory for the service.


Data directory for the service.


Log directory for the service.


Backup directory for the service.


Configuration file of the service.


PID file of the service instance.


Standard Output log file of the service.


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: Optional[int] = 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.