fundamentals.daemonise¶
helper class to daemonise you code
- Author
David Young
- Date Created
May 23, 2023
Module Contents¶
Classes¶
A class to daemonise a python code |
API¶
- class fundamentals.daemonise.daemonise(log, name, **akws)[source][source]¶
A class to daemonise a python code
Key Arguments:
log– loggername– a name for the daemon (e.g. python package name)
Usage:
Add something like this to your command-line usage:
Usage: myCommand (start|stop|restart|status) Options: start start the myCommand daemon stop stop the myCommand daemon restart restart the myCommand daemon status print the staus of the myCommand daemonand then when executing the commands:
from fundamental import daemonise class myDaemon(daemonise): def action( self, **kwargs): self.log.info('starting the ``action`` method') anotherParameter = kwargs["anotherParameter"] import time while True: print(f"OVERRIDE ACTION - {anotherParameter}") time.sleep(3) self.log.info('completed the ``action`` method') return None d = myDaemon(log=log, name="gocart", anotherParameter=42.) if a['start']: d.start() elif a['stop']: d.stop() elif a['restart']: d.restart() elif a['status']: d.status()
Replace
**akwswith any keywords you need.Initialization