gocron

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2015 License: MIT Imports: 12 Imported by: 5

README

go-cron

Simple golang wrapper over github.com/robfig/cron and os/exec as a cron replacement. Additionally the application opens a HTTP port that can be used as a healthcheck.

usage

go-cron -s "* * * * * *" -p 8080 -- /bin/bash -c "echo 1"

Check the healthcheck:

$ curl -v localhost:18080
* Rebuilt URL to: localhost:18080/
* Hostname was NOT found in DNS cache
*   Trying ::1...
* Connected to localhost (::1) port 18080 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:18080
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Wed, 11 Mar 2015 12:59:07 GMT
< Content-Length: 237
<
{
  "Running": {},
  "Last": {
    "Exit_status": 0,
    "Stdout": "1\n",
    "Stderr": "",
    "ExitTime": "2015-03-11T13:59:05+01:00",
    "Pid": 14420,
    "StartingTime": "2015-03-11T13:59:05+01:00"
  },
  "Schedule": "*/5 * * * *"
* Connection #0 to host localhost left intact
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create added in v0.0.5

func Create(schedule string, command string, args []string) (cr *cron.Cron, wgr *sync.WaitGroup)

func Http_server added in v0.0.5

func Http_server(port string)

func Start added in v0.0.5

func Start(c *cron.Cron)

func Stop added in v0.0.5

func Stop(c *cron.Cron, wg *sync.WaitGroup)

Types

type CurrentState added in v0.0.5

type CurrentState struct {
	Running  map[string]*LastRun
	Last     *LastRun
	Schedule string
}
var Current_state CurrentState

type LastRun

type LastRun struct {
	Exit_status  int
	Stdout       string
	Stderr       string
	ExitTime     string
	Pid          int
	StartingTime string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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