Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wkharold/jobd
https://github.com/wkharold/jobd
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/wkharold/jobd
- Owner: wkharold
- License: bsd-3-clause
- Created: 2013-11-22T04:23:24.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-03T17:52:07.000Z (almost 10 years ago)
- Last Synced: 2024-08-01T13:16:35.458Z (3 months ago)
- Language: Go
- Homepage:
- Size: 488 KB
- Stars: 28
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-9p - jobd - Cron as a file system (Servers / Go)
README
#jobd
Jobd implements *cron* as a 9p file system. 9p is [a simple file protocol to
build sane distributed systems](http://9p.cat-v.org/). It's the cornerstone of
[the Styx Architecture for Distributed
Systems](http://doc.cat-v.org/inferno/4th_edition/styx) which represents the
system's resources as a form of file system. Jobd illustrates this approach to
system design using the [go9p](https://code.google.com/p/go9p) library.##Installation
jobd uses [godep](https://github.com/tools/godep) to capture its dependencies. To install it just
```
$ go get github.com/wkharold/jobd
```
To build it, make sure you have godep installed and then
```
$ godep go install
```##Usage
```
jobd --help
Usage of jobd:
-alsologtostderr=false: log to standard error as well as files
-dbdir="/var/lib/jobd": Location of the jobd jobs database
-debug=false: 9p debugging to stderr
-fsaddr="0.0.0.0:5640": Address where job file service listens for connections
-log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
-log_dir="": If non-empty, write log files in this directory
-logtostderr=false: log to standard error instead of files
-stderrthreshold=0: logs at or above this threshold go to stderr
-v=0: log level for V logs
-vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```Once jobd is started the file system it provides can be mounted via
```
$ mount -t 9p -o protocol=tcp,port=5640
```
Where **addr** is the IP address of the box running jobd. Note that it needn't be mounted on the machine running jobd, any box running a Linux 3.x kernel should suffice.##Design
*cron* is a time-based job scheduler, it has two primary concerns: *jobs* which are commands to be executed, and *schedules* that determine when a job is run. The design of a 9p-based application or system service generally begins with the creation of a *name space*, think file system subtree, that represents the application's resources in terms of files and directories.
Jobd represents jobs as subdirectories of a *jobs* directory. Each *job* subdirectory contains four files:
* the **ctl** file which is used to start and stop the job
* the **cmd** file that records the command the job executes
* the **log** file that is used to retrieve the job's execution history
* the **schedule** file that records the job's schedule and its next scheduled execution timeTo start a job, write the string **start** to the *ctl* file
```
$ echo -n start > /jobs//ctl
```
Similarly to stop it write the string **stop** to the *ctl* file
```
$ echo -n stop > /jobs//ctl
```
Read from the *cmd*, *log*, or *schedule* file to retrieve the information they provide
```
$ cat /jobs//cmd
echo hello world
$ cat /jobs//schedule
0 0/5 * * * ? *
$ cat /jobs//log
2014-02-11 09:42:33.454707331 -0600 CST:started
2014-02-11 09:42:35.004655691 -0600 CST:hello world
2014-02-11 09:42:40.003579265 -0600 CST:hello world
2014-02-11 09:42:45.003220637 -0600 CST:hello world
2014-02-11 09:42:50.00294003 -0600 CST:hello world
...
```Jobd jobs are created via the *clone* file. The *clone* file is a peer of the *jobs* directory in the jobd name space. To create a job write a string of the form: :: to the clone file
```
$ echo -n 'hello:0 0/5 * * * ? *:echo hello world' > /clone
```##TODO
* support deleting jobs