{"action":"created","comment":{"url":"https://api.github.com/repos/joyent/containerpilot/pulls/comments/60417492","id":60417492,"diff_hunk":"@@ -0,0 +1,194 @@\n+package tasks\n+\n+import (\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"os/exec\"\n+\t\"strings\"\n+\t\"time\"\n+\n+\tlog \"github.com/Sirupsen/logrus\"\n+\t\"github.com/joyent/containerpilot/utils\"\n+)\n+\n+// TaskConfig configures tasks that run periodically\n+type TaskConfig struct {\n+\tName      string   `json:\"name\"`\n+\tArgs      []string `json:\"command\"`\n+\tFrequency string   `json:\"frequency\"`\n+\tTimeout   string   `json:\"timeout,omitempty\"`\n+\n+\tfreqDuration    time.Duration\n+\ttimeoutDuration time.Duration\n+\tcmd             *exec.Cmd\n+\tquitChannel     chan int","path":"tasks/tasks.go","position":null,"original_position":25,"commit_id":"067b533e6267a70a8355d9b794a9ca5158a48d7a","original_commit_id":"8e9f359eb82c4638edf9b725106afa3a7286883d","user":{"login":"tgross","id":1409219,"avatar_url":"https://avatars.githubusercontent.com/u/1409219?v=3","gravatar_id":"","url":"https://api.github.com/users/tgross","html_url":"https://github.com/tgross","followers_url":"https://api.github.com/users/tgross/followers","following_url":"https://api.github.com/users/tgross/following{/other_user}","gists_url":"https://api.github.com/users/tgross/gists{/gist_id}","starred_url":"https://api.github.com/users/tgross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgross/subscriptions","organizations_url":"https://api.github.com/users/tgross/orgs","repos_url":"https://api.github.com/users/tgross/repos","events_url":"https://api.github.com/users/tgross/events{/privacy}","received_events_url":"https://api.github.com/users/tgross/received_events","type":"User","site_admin":false},"body":"Yeah, I like that approach.\r\n\r\nAnd, for a bonus, it lets us start a future bikeshed about whether polling for Service and Backend [should take fractional seconds](http://bikeshed.com/). 😀 ","created_at":"2016-04-20T14:30:06Z","updated_at":"2016-04-20T14:30:06Z","html_url":"https://github.com/joyent/containerpilot/pull/134#discussion_r60417492","pull_request_url":"https://api.github.com/repos/joyent/containerpilot/pulls/134","_links":{"self":{"href":"https://api.github.com/repos/joyent/containerpilot/pulls/comments/60417492"},"html":{"href":"https://github.com/joyent/containerpilot/pull/134#discussion_r60417492"},"pull_request":{"href":"https://api.github.com/repos/joyent/containerpilot/pulls/134"}}},"pull_request":{"url":"https://api.github.com/repos/joyent/containerpilot/pulls/134","id":66589735,"html_url":"https://github.com/joyent/containerpilot/pull/134","diff_url":"https://github.com/joyent/containerpilot/pull/134.diff","patch_url":"https://github.com/joyent/containerpilot/pull/134.patch","issue_url":"https://api.github.com/repos/joyent/containerpilot/issues/134","number":134,"state":"open","locked":false,"title":"Implement Periodic Tasks","user":{"login":"justenwalker","id":222027,"avatar_url":"https://avatars.githubusercontent.com/u/222027?v=3","gravatar_id":"","url":"https://api.github.com/users/justenwalker","html_url":"https://github.com/justenwalker","followers_url":"https://api.github.com/users/justenwalker/followers","following_url":"https://api.github.com/users/justenwalker/following{/other_user}","gists_url":"https://api.github.com/users/justenwalker/gists{/gist_id}","starred_url":"https://api.github.com/users/justenwalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justenwalker/subscriptions","organizations_url":"https://api.github.com/users/justenwalker/orgs","repos_url":"https://api.github.com/users/justenwalker/repos","events_url":"https://api.github.com/users/justenwalker/events{/privacy}","received_events_url":"https://api.github.com/users/justenwalker/received_events","type":"User","site_admin":false},"body":"For #87 (Periodic Tasks)\r\n\r\n## Periodic Tasks\r\n\r\nThis feature adds periodic tasks which are defined by a new `tasks` section which is array of objects such as:\r\n\r\n```json\r\n\"tasks\": [\r\n    {\r\n      \"name\": \"task\",\r\n      \"command\": [\"/bin/task.sh\",\"arg1\"],\r\n      \"frequency\": \"1500ms\",\r\n      \"timeout\": \"100ms\"\r\n    }\r\n  ]\r\n```\r\n\r\nMore information on usage is in the README\r\n\r\n## Integration Tests - Single Test\r\n\r\nI found it useful to run a single integration test at a time. I added that capability to the Makefile.\r\n\r\n```\r\n$ make integration TEST=test_tasks\r\n```\r\n\r\n## utils.NewLogWriter\r\n\r\nOne thing of note is that there are now a lot of commands mapping standard out/standard error directly to the main stderr/stdout. This is problematic if I like to keep my shimmed application logging to stdout and ContainerPilot to stderr.\r\n\r\nI put in a utility function `utils. NewLogWriter ` which can be used as a pipe to `logrus`. This basically makes these commands log using the preferred logging framework rather than raw standard out/standard err. It might be generally useful for the other ancillary commands like `preStart` `preStop` `postStop` and anything else we run that is not the shimmed application.","created_at":"2016-04-15T04:44:23Z","updated_at":"2016-04-20T14:30:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"09ae445488fd94554fd9c92514b1de277f957501","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/joyent/containerpilot/pulls/134/commits","review_comments_url":"https://api.github.com/repos/joyent/containerpilot/pulls/134/comments","review_comment_url":"https://api.github.com/repos/joyent/containerpilot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/joyent/containerpilot/issues/134/comments","statuses_url":"https://api.github.com/repos/joyent/containerpilot/statuses/067b533e6267a70a8355d9b794a9ca5158a48d7a","head":{"label":"justenwalker:gh87_periodic-tasks","ref":"gh87_periodic-tasks","sha":"067b533e6267a70a8355d9b794a9ca5158a48d7a","user":{"login":"justenwalker","id":222027,"avatar_url":"https://avatars.githubusercontent.com/u/222027?v=3","gravatar_id":"","url":"https://api.github.com/users/justenwalker","html_url":"https://github.com/justenwalker","followers_url":"https://api.github.com/users/justenwalker/followers","following_url":"https://api.github.com/users/justenwalker/following{/other_user}","gists_url":"https://api.github.com/users/justenwalker/gists{/gist_id}","starred_url":"https://api.github.com/users/justenwalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justenwalker/subscriptions","organizations_url":"https://api.github.com/users/justenwalker/orgs","repos_url":"https://api.github.com/users/justenwalker/repos","events_url":"https://api.github.com/users/justenwalker/events{/privacy}","received_events_url":"https://api.github.com/users/justenwalker/received_events","type":"User","site_admin":false},"repo":{"id":47218030,"name":"containerpilot","full_name":"justenwalker/containerpilot","owner":{"login":"justenwalker","id":222027,"avatar_url":"https://avatars.githubusercontent.com/u/222027?v=3","gravatar_id":"","url":"https://api.github.com/users/justenwalker","html_url":"https://github.com/justenwalker","followers_url":"https://api.github.com/users/justenwalker/followers","following_url":"https://api.github.com/users/justenwalker/following{/other_user}","gists_url":"https://api.github.com/users/justenwalker/gists{/gist_id}","starred_url":"https://api.github.com/users/justenwalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justenwalker/subscriptions","organizations_url":"https://api.github.com/users/justenwalker/orgs","repos_url":"https://api.github.com/users/justenwalker/repos","events_url":"https://api.github.com/users/justenwalker/events{/privacy}","received_events_url":"https://api.github.com/users/justenwalker/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/justenwalker/containerpilot","description":"A service for autodiscovery and configuration of applications running in containers","fork":true,"url":"https://api.github.com/repos/justenwalker/containerpilot","forks_url":"https://api.github.com/repos/justenwalker/containerpilot/forks","keys_url":"https://api.github.com/repos/justenwalker/containerpilot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/justenwalker/containerpilot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/justenwalker/containerpilot/teams","hooks_url":"https://api.github.com/repos/justenwalker/containerpilot/hooks","issue_events_url":"https://api.github.com/repos/justenwalker/containerpilot/issues/events{/number}","events_url":"https://api.github.com/repos/justenwalker/containerpilot/events","assignees_url":"https://api.github.com/repos/justenwalker/containerpilot/assignees{/user}","branches_url":"https://api.github.com/repos/justenwalker/containerpilot/branches{/branch}","tags_url":"https://api.github.com/repos/justenwalker/containerpilot/tags","blobs_url":"https://api.github.com/repos/justenwalker/containerpilot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/justenwalker/containerpilot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/justenwalker/containerpilot/git/refs{/sha}","trees_url":"https://api.github.com/repos/justenwalker/containerpilot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/justenwalker/containerpilot/statuses/{sha}","languages_url":"https://api.github.com/repos/justenwalker/containerpilot/languages","stargazers_url":"https://api.github.com/repos/justenwalker/containerpilot/stargazers","contributors_url":"https://api.github.com/repos/justenwalker/containerpilot/contributors","subscribers_url":"https://api.github.com/repos/justenwalker/containerpilot/subscribers","subscription_url":"https://api.github.com/repos/justenwalker/containerpilot/subscription","commits_url":"https://api.github.com/repos/justenwalker/containerpilot/commits{/sha}","git_commits_url":"https://api.github.com/repos/justenwalker/containerpilot/git/commits{/sha}","comments_url":"https://api.github.com/repos/justenwalker/containerpilot/comments{/number}","issue_comment_url":"https://api.github.com/repos/justenwalker/containerpilot/issues/comments{/number}","contents_url":"https://api.github.com/repos/justenwalker/containerpilot/contents/{+path}","compare_url":"https://api.github.com/repos/justenwalker/containerpilot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/justenwalker/containerpilot/merges","archive_url":"https://api.github.com/repos/justenwalker/containerpilot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/justenwalker/containerpilot/downloads","issues_url":"https://api.github.com/repos/justenwalker/containerpilot/issues{/number}","pulls_url":"https://api.github.com/repos/justenwalker/containerpilot/pulls{/number}","milestones_url":"https://api.github.com/repos/justenwalker/containerpilot/milestones{/number}","notifications_url":"https://api.github.com/repos/justenwalker/containerpilot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/justenwalker/containerpilot/labels{/name}","releases_url":"https://api.github.com/repos/justenwalker/containerpilot/releases{/id}","deployments_url":"https://api.github.com/repos/justenwalker/containerpilot/deployments","created_at":"2015-12-01T21:18:18Z","updated_at":"2016-04-13T02:28:11Z","pushed_at":"2016-04-20T12:26:57Z","git_url":"git://github.com/justenwalker/containerpilot.git","ssh_url":"git@github.com:justenwalker/containerpilot.git","clone_url":"https://github.com/justenwalker/containerpilot.git","svn_url":"https://github.com/justenwalker/containerpilot","homepage":null,"size":381,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"joyent:master","ref":"master","sha":"0a8d706edef92ecb0102530b0394b1568831be2a","user":{"login":"joyent","id":10161,"avatar_url":"https://avatars.githubusercontent.com/u/10161?v=3","gravatar_id":"","url":"https://api.github.com/users/joyent","html_url":"https://github.com/joyent","followers_url":"https://api.github.com/users/joyent/followers","following_url":"https://api.github.com/users/joyent/following{/other_user}","gists_url":"https://api.github.com/users/joyent/gists{/gist_id}","starred_url":"https://api.github.com/users/joyent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyent/subscriptions","organizations_url":"https://api.github.com/users/joyent/orgs","repos_url":"https://api.github.com/users/joyent/repos","events_url":"https://api.github.com/users/joyent/events{/privacy}","received_events_url":"https://api.github.com/users/joyent/received_events","type":"Organization","site_admin":false},"repo":{"id":44767194,"name":"containerpilot","full_name":"joyent/containerpilot","owner":{"login":"joyent","id":10161,"avatar_url":"https://avatars.githubusercontent.com/u/10161?v=3","gravatar_id":"","url":"https://api.github.com/users/joyent","html_url":"https://github.com/joyent","followers_url":"https://api.github.com/users/joyent/followers","following_url":"https://api.github.com/users/joyent/following{/other_user}","gists_url":"https://api.github.com/users/joyent/gists{/gist_id}","starred_url":"https://api.github.com/users/joyent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyent/subscriptions","organizations_url":"https://api.github.com/users/joyent/orgs","repos_url":"https://api.github.com/users/joyent/repos","events_url":"https://api.github.com/users/joyent/events{/privacy}","received_events_url":"https://api.github.com/users/joyent/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/joyent/containerpilot","description":"A service for autodiscovery and configuration of applications running in containers","fork":false,"url":"https://api.github.com/repos/joyent/containerpilot","forks_url":"https://api.github.com/repos/joyent/containerpilot/forks","keys_url":"https://api.github.com/repos/joyent/containerpilot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joyent/containerpilot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joyent/containerpilot/teams","hooks_url":"https://api.github.com/repos/joyent/containerpilot/hooks","issue_events_url":"https://api.github.com/repos/joyent/containerpilot/issues/events{/number}","events_url":"https://api.github.com/repos/joyent/containerpilot/events","assignees_url":"https://api.github.com/repos/joyent/containerpilot/assignees{/user}","branches_url":"https://api.github.com/repos/joyent/containerpilot/branches{/branch}","tags_url":"https://api.github.com/repos/joyent/containerpilot/tags","blobs_url":"https://api.github.com/repos/joyent/containerpilot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joyent/containerpilot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joyent/containerpilot/git/refs{/sha}","trees_url":"https://api.github.com/repos/joyent/containerpilot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joyent/containerpilot/statuses/{sha}","languages_url":"https://api.github.com/repos/joyent/containerpilot/languages","stargazers_url":"https://api.github.com/repos/joyent/containerpilot/stargazers","contributors_url":"https://api.github.com/repos/joyent/containerpilot/contributors","subscribers_url":"https://api.github.com/repos/joyent/containerpilot/subscribers","subscription_url":"https://api.github.com/repos/joyent/containerpilot/subscription","commits_url":"https://api.github.com/repos/joyent/containerpilot/commits{/sha}","git_commits_url":"https://api.github.com/repos/joyent/containerpilot/git/commits{/sha}","comments_url":"https://api.github.com/repos/joyent/containerpilot/comments{/number}","issue_comment_url":"https://api.github.com/repos/joyent/containerpilot/issues/comments{/number}","contents_url":"https://api.github.com/repos/joyent/containerpilot/contents/{+path}","compare_url":"https://api.github.com/repos/joyent/containerpilot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joyent/containerpilot/merges","archive_url":"https://api.github.com/repos/joyent/containerpilot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joyent/containerpilot/downloads","issues_url":"https://api.github.com/repos/joyent/containerpilot/issues{/number}","pulls_url":"https://api.github.com/repos/joyent/containerpilot/pulls{/number}","milestones_url":"https://api.github.com/repos/joyent/containerpilot/milestones{/number}","notifications_url":"https://api.github.com/repos/joyent/containerpilot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joyent/containerpilot/labels{/name}","releases_url":"https://api.github.com/repos/joyent/containerpilot/releases{/id}","deployments_url":"https://api.github.com/repos/joyent/containerpilot/deployments","created_at":"2015-10-22T19:06:39Z","updated_at":"2016-04-20T14:14:13Z","pushed_at":"2016-04-20T09:47:38Z","git_url":"git://github.com/joyent/containerpilot.git","ssh_url":"git@github.com:joyent/containerpilot.git","clone_url":"https://github.com/joyent/containerpilot.git","svn_url":"https://github.com/joyent/containerpilot","homepage":null,"size":392,"stargazers_count":317,"watchers_count":317,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":12,"forks":31,"open_issues":12,"watchers":317,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/joyent/containerpilot/pulls/134"},"html":{"href":"https://github.com/joyent/containerpilot/pull/134"},"issue":{"href":"https://api.github.com/repos/joyent/containerpilot/issues/134"},"comments":{"href":"https://api.github.com/repos/joyent/containerpilot/issues/134/comments"},"review_comments":{"href":"https://api.github.com/repos/joyent/containerpilot/pulls/134/comments"},"review_comment":{"href":"https://api.github.com/repos/joyent/containerpilot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/joyent/containerpilot/pulls/134/commits"},"statuses":{"href":"https://api.github.com/repos/joyent/containerpilot/statuses/067b533e6267a70a8355d9b794a9ca5158a48d7a"}}}}