Package: drummer
DrummerDrummer is a python multi-process and multi-task job scheduler for Linux, best served as a systemd service. You can create jobs with your own tasks, and you can decide the execution flow depending on the outcome of each task.For instance: if task A succeeds, then execute task B; if it fails, then execute task C. And, no matter the result of A, always do execute also task D.Drummer is heavily insipired byComodojo Extender: I wish therefore to acknowledge its author.Quick startInstallation is quick and easy.> pip install drummerSpecify a folder where to init Drummer environment and, optionally, a filename for the internal database.> drummer-admin init BASE_FOLDER [--database database_file]During the initialization, Drummer will ask whether it should create also the related Linux systemd service file (this is the recommended choice). It will ask also which python executable to use, should you use a Virtualenv installation.Now you arealmostready to start.How Drummer worksDrummer machinery is composed of three processes:a scheduler process, built on top ofsched modulea socket listener, to handle requests and responses with the Drummer clia main process, which puts together all pieces and takes care of the overall behaviourIn order to ensure the multi-tasking capability, each task is run by a separate process.When you create a new environment for Drummer, you will notice several files and folders being created:theconfigfolder, for configuration and task file and, if you chose so, the systemd file;adatabasefolder, which contains the internal sqlite database with schedules;atasksfolder, for placing your tasks;the CLI launcher,drummer-cli.py.ConfigurationConfiguration is stored in filedrummer-config.yml.Among all, you can specify where to store the log file and the database, which folder to use for your tasks (by default, Drummer looks for them inside thetasksfolder), how many task can be runned at the same time, and so on.TasksTo be well formed, user-defined tasks should respect few basic requirements, i.e. they:extend theTaskclass provided bydrummermoduleimplement arunmethod as execution entry pointuse theResponseclass, along with a validStatusCode, for handling the task outcome (validStatusCodeattributes are: "STATUS_OK", "STATUS_WARNING", "STATUS_ERROR")A fully working example:from drummer import Task, Response, StatusCode

class MyTask(Task):

    def run(self, params):

        # the Drummer logger, built on top of python logging facility
        logger = self.logger

        logger.info('Starting MyTask')

        response = Response()

        try:

            with open('mytask.txt', 'w') as f:
                f.write('Hello world!')

            logger.info('File has been updated')

            response.set_status(StatusCode.STATUS_OK)
            response.set_data({'result': 'Task ended OK'})

        except:

            response.set_status(StatusCode.STATUS_ERROR)
            response.set_data({'result': 'Task had an error'})

        finally:

            return responseTherunmethod takes a dictionary with optional task arguments. It is empty if no arguments are specified.To complete the registration process, you have to declare the task, along with its path, insidedrummer-tasks.yml. Drummer must know the path of python file to load (expressed as relative path with respect to base folder), and the name of the class which exposed therunmethod.You can automatically update the task list with thetask:updatecommand. Drummer will parse all valid tasks found inside thetaskdirfolder.Of course you can alsoinityour task class; in that case, you must take care of configuration and logger, as in the following:from drummer import Task

class MyTask(Task):

    def __init__(self, config, logger):

        # init Task class
        super().__init__(config, logger)

        # your init code here
        # ...cliYou can start Drummer in two ways: as a systemd service (viasystemctlcommand) or with cli, by invoking theservice:startcommand.> python drummer-cli.py service:startThe cli provides commands to:list all jobs and get info on a single jobadd, remove, enable, disable, or immediately execute a schedulelist and execute single tasksautomatically register valid tasksimport and export the schedulation tableFor details see:> python drummer-cli.py -h