Simple
A service is a singleton object on each node that provides a shared interface to any running agent. To add a new service, place a python file in the modules directory that inherits from theService class defined in addons.py and make sure it is in the dependency tree.
When the node daemon process is started, a singleton object will be created and the service will be available to all of the agents via the services import. Most agents calls will all come from the same thread. However, it is possible that calls could some from different threads for appropriate actions should be taken. An example service is:
class ApacheService(modules.Service):
DEPENDS = []
SOFTWARE = ["apache22"]
def __init__(self):
self.count = 0
def start(self):
self.count += 1
if self.count == 1:
log.info("Starting apache server")
run("apachectl -f /usr/local/apache/conf/httpd.conf -k start", log)
def stop(self):
self.count -= 1
if self.count == 0:
log.info("Stopping apache server")
run("apachectl -f /usr/local/apache/conf/httpd.conf -k stop", log)