API Documentation¶
crawler¶
-
class
cronster.crawler.
CronsterCrawler
(root, cache_host, cache_port, interval)[source]¶ Bases:
object
Cronster crawler class. Crawl the file system recursively for
crontab
files, read the contents and store a list ofCronsterJob
in a Redis cache.-
__init__
(root, cache_host, cache_port, interval)[source]¶ Initialise a
CronsterCrawler
.Parameters:
-
crawl
()[source]¶ Recursively crawl the file system from
root
in a giveninterval
. AddCronsterJob
fromcrontab
files to the cache as a JSON string.
-
get_crontab_data
(crontab)[source]¶ Given a
crontab
file path, load and return theCronsterJob
contained in the file.Parameters: crontab (str) – Crontab file path Returns: Jobs Return type: list Example output:
[ { "name": "job_name", "cmd": "echo $PATH", "schedule": "* * * * *", "path": "/path/to/crontab/file", "hash": "dc8a776c99d9b8ab97550e87c857dc959a857c5b" } ]
-
scheduler¶
-
class
cronster.scheduler.
CronsterJob
(job_name, job_cmd, job_schedule, job_path, job_hash)[source]¶ Bases:
object
Cronster job class. Representation of an individual cronster job.
-
__init__
(job_name, job_cmd, job_schedule, job_path, job_hash)[source]¶ Initialise a
CronsterJob
.Parameters:
-
-
class
cronster.scheduler.
CronsterScheduler
(cache_host, cache_port)[source]¶ Bases:
object
Cronster scheduler class. Load jobs from a Redis cache and run any number of
CronsterJob
based on their schedule.-
__init__
(cache_host, cache_port)[source]¶ Initialise a
CronsterScheduler
.Parameters:
-
-
class
cronster.scheduler.
CronsterSchedulerPrompt
(scheduler)[source]¶ Bases:
cmd.Cmd
Cronster command prompt class. Implement CLI commands to control the attached
CronsterScheduler
.-
__init__
(scheduler)[source]¶ Initialise a
CronsterSchedulerPrompt
.Parameters: scheduler ( CronsterScheduler
) – Scheduler to control
-
do_clear
(args)[source]¶ Invoke
cronster.scheduler.CronsterScheduler.clear()
to clear the job queue.
-
do_start
(args)[source]¶ Invoke
cronster.scheduler.CronsterScheduler.start()
to start the scheduler.
-
do_status
(args)[source]¶ Invoke
cronster.scheduler.CronsterScheduler.status()
and print the status information to the console.
-
do_stop
(args)[source]¶ Invoke
cronster.scheduler.CronsterScheduler.stop()
to stop the scheduler.
-
do_update
(args)[source]¶ Invoke
cronster.scheduler.CronsterScheduler.update()
to force a job update form the cache.
-
-
cronster.scheduler.
_update_loop
(scheduler)[source]¶ Run an infinite update/run loop.
Parameters: scheduler ( CronsterScheduler
) – Scheduler to run
-
cronster.scheduler.
run_scheduler
(cache_host, cache_port)[source]¶ Instantiate and run a
CronsterScheduler
. Run its run/update loop in a separate thread.Parameters: