jobd

command module
v0.0.0-...-9cb30a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2015 License: BSD-3-Clause Imports: 15 Imported by: 0

README

#jobd

Jobd implements cron as a 9p file system. 9p is a simple file protocol to build sane distributed systems. It's the cornerstone of the Styx Architecture for Distributed Systems which represents the system's resources as a form of file system. Jobd illustrates this approach to system design using the go9p library.

##Installation

jobd uses 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 <addr> <mountpoint>

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 time

To start a job, write the string start to the ctl file

$ echo -n start > <mountpoint>/jobs/<job>/ctl

Similarly to stop it write the string stop to the ctl file

$ echo -n stop > <mountpoint>/jobs/<job>/ctl

Read from the cmd, log, or schedule file to retrieve the information they provide

$ cat <mountpoint>/jobs/<job>/cmd
echo hello world
$ cat <mountpoint>/jobs/<job>/schedule
0 0/5 * * * ? *
$ cat <mountpoint>/jobs/<job>/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' > <mountpoint>/clone

##TODO

  • support deleting jobs

Documentation

Overview

jobd is a 9p server that executes jobs - standard Unix command lines a'la cron.

Directories

Path Synopsis
Godeps
_workspace/src/code.google.com/p/go9p/p
The p9 package provides the definitions and functions used to implement the 9P2000 protocol.
The p9 package provides the definitions and functions used to implement the 9P2000 protocol.
_workspace/src/code.google.com/p/go9p/p/clnt
The clnt package provides definitions and functions used to implement a 9P2000 file client.
The clnt package provides definitions and functions used to implement a 9P2000 file client.
_workspace/src/code.google.com/p/go9p/p/clnt/examples/tls
Connects to a server over TLS and lists the specified directory
Connects to a server over TLS and lists the specified directory
_workspace/src/code.google.com/p/go9p/p/srv
The srv package provides definitions and functions used to implement a 9P2000 file server.
The srv package provides definitions and functions used to implement a 9P2000 file server.
_workspace/src/code.google.com/p/go9p/p/srv/examples/tlsramfs
Listen on SSL connection, can be used as an example with p/clnt/examples/tls.go Sample certificate was copied from the Go source code
Listen on SSL connection, can be used as an example with p/clnt/examples/tls.go Sample certificate was copied from the Go source code
_workspace/src/github.com/golang/glog
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
_workspace/src/github.com/gorhill/cronexpr
Package cronexpr parses cron time expressions.
Package cronexpr parses cron time expressions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL