{"action":"created","comment":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments/52097012","id":52097012,"diff_hunk":"@@ -1,17 +1,61 @@\n # Manages the user crontab for scheduled apps-related tasks.\n+root = File.join node[:home], node.chef_environment\n+bin = File.join root, 'bin'\n \n-template \"/home/#{node[:current_user]}/#{node.chef_environment}/crontab\" do\n-  source 'crontab.erb'\n-  user node[:current_user]\n-  group node[:current_user]\n-  mode '0644'\n-  notifies :run, 'execute[install-crontab]', :immediately\n+def cronjob(m:nil, at:nil, cmd:, h:nil, notify:'')\n+  cron cmd do\n+    time at if at\n+    minute m.to_s if m\n+    hour h.to_s if h\n+    user node[:user]\n+    root = File.join node[:home], node.chef_environment\n+    bin = File.join root, 'bin'\n+    environment node['cdo-apps']['bundle_env']\n+    require 'shellwords'\n+    command \"bundle exec #{bin}/cronjob #{cmd.shellescape} #{notify}\"\n+    mailto 'dev+crontab@code.org'\n+  end\n end\n \n-execute 'install-crontab' do\n-  command 'cat ./crontab | crontab -'\n-  cwd \"/home/#{node[:current_user]}/#{node.chef_environment}\"\n-  user node[:current_user]\n-  group node[:current_user]\n-  action :nothing\n+# for multi-instance envs (ie production) there should be one daemon,\n+# so cronjobs that run once per environment go here (standalone env\n+# instances are all their own daemon)\n+if node['cdo-apps']['daemon']\n+  unless node.chef_environment == 'production' # non-production daemons\n+    cronjob at: :reboot, cmd: \"#{bin}/solr-server > #{root}/pegasus/log/solr.log 2>&1\"\n+  end\n+\n+  if node.chef_environment == 'staging' && node.name == 'staging' # 'real' staging only\n+    cronjob at: :reboot, cmd: \"#{node[:home]}/.dropbox-dist/dropboxd\"\n+    cronjob m:'*/2', cmd: \"#{root}/pegasus/sites/virtual/run_server_generate_curriculum_pdfs\", notify: 'dev+crontab@code.org'\n+    cronjob m:'*/2', cmd: \"#{root}/pegasus/sites/virtual/collate_pdfs\", notify: 'dev+crontab@code.org'\n+    cronjob m:'*/2', cmd: \"#{root}/dashboard/bin/build_scripts\", notify: 'dev+crontab@code.org'\n+    cronjob m:'*/2', cmd: \"#{bin}/run_server_generate_pdfs\", notify: 'dev+crontab@code.org'\n+    cronjob m:'*/5', cmd: \"#{bin}/fetch-external-resources\", notify:'dev+crontab@code.org'\n+    cronjob m:'*/5', cmd: \"#{bin}/import_google_sheets\"\n+  end\n+\n+  if node.chef_environment == 'production' # production daemon\n+    cronjob m:'*/1',    cmd: \"#{bin}/index-users-in-solr\"\n+    cronjob h:6,  m:5,  cmd: \"#{bin}/send_workshop_reminder_emails\"\n+    cronjob h:7,  m:25, cmd: \"#{bin}/update-hoc-map\"","path":"cookbooks/cdo-apps/recipes/crontab.rb","position":53,"original_position":53,"commit_id":"53bbba8b8952d4a7be6d09a80a97c27e1730be2d","original_commit_id":"53bbba8b8952d4a7be6d09a80a97c27e1730be2d","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Style/SpaceAfterColon: Space missing after colon.","created_at":"2016-02-06T03:22:19Z","updated_at":"2016-02-06T03:22:19Z","html_url":"https://github.com/code-dot-org/code-dot-org/pull/6691#discussion_r52097012","pull_request_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/6691","_links":{"self":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments/52097012"},"html":{"href":"https://github.com/code-dot-org/code-dot-org/pull/6691#discussion_r52097012"},"pull_request":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/6691"}}},"pull_request":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/6691","id":58510040,"html_url":"https://github.com/code-dot-org/code-dot-org/pull/6691","diff_url":"https://github.com/code-dot-org/code-dot-org/pull/6691.diff","patch_url":"https://github.com/code-dot-org/code-dot-org/pull/6691.patch","issue_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/6691","number":6691,"state":"open","locked":false,"title":"Cdo apps refactor","user":{"login":"wjordan","id":56541,"avatar_url":"https://avatars.githubusercontent.com/u/56541?v=3","gravatar_id":"","url":"https://api.github.com/users/wjordan","html_url":"https://github.com/wjordan","followers_url":"https://api.github.com/users/wjordan/followers","following_url":"https://api.github.com/users/wjordan/following{/other_user}","gists_url":"https://api.github.com/users/wjordan/gists{/gist_id}","starred_url":"https://api.github.com/users/wjordan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wjordan/subscriptions","organizations_url":"https://api.github.com/users/wjordan/orgs","repos_url":"https://api.github.com/users/wjordan/repos","events_url":"https://api.github.com/users/wjordan/events{/privacy}","received_events_url":"https://api.github.com/users/wjordan/received_events","type":"User","site_admin":false},"body":"Follow-on PR to #6646 and prerequisite for merging the branch.\r\n\r\nExtra set of cookbook refactorings needed to get the end-to-end cdo-apps integration test working using the ec2 driver:\r\n\r\n```\r\ncode-dot-org/cookbooks/cdo-apps$ time KITCHEN_LOCAL_YAML=../.kitchen.ec2.yml bundle exec kitchen verify\r\n\r\n[...]\r\n\r\n       Command \"curl localhost:8080\"\r\n         stdout\r\n           should match \"<title>Code\\\\.org\\\\ \\\\[adhoc\\\\]</title>\"\r\n       \r\n       Command \"curl localhost:8081\"\r\n         stdout\r\n           should match \"<title>Anybody\\\\ can\\\\ learn\\\\ \\\\|\\\\ Code\\\\.org</title>\"\r\n       \r\n       Finished in 1.91 seconds (files took 0.27207 seconds to load)\r\n       2 examples, 0 failures\r\n       \r\n       Finished verifying <default-ubuntu-1404> (0m18.05s).\r\n-----> Kitchen is finished. (16m15.80s)\r\n\r\nreal\t16m16.522s\r\nuser\t0m3.276s\r\nsys\t0m0.448s\r\n```","created_at":"2016-02-06T03:22:12Z","updated_at":"2016-02-06T03:22:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"55a0953773a15365a08784ae6f487afb84a9adea","assignee":{"login":"philbogle","id":5198586,"avatar_url":"https://avatars.githubusercontent.com/u/5198586?v=3","gravatar_id":"","url":"https://api.github.com/users/philbogle","html_url":"https://github.com/philbogle","followers_url":"https://api.github.com/users/philbogle/followers","following_url":"https://api.github.com/users/philbogle/following{/other_user}","gists_url":"https://api.github.com/users/philbogle/gists{/gist_id}","starred_url":"https://api.github.com/users/philbogle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philbogle/subscriptions","organizations_url":"https://api.github.com/users/philbogle/orgs","repos_url":"https://api.github.com/users/philbogle/repos","events_url":"https://api.github.com/users/philbogle/events{/privacy}","received_events_url":"https://api.github.com/users/philbogle/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/6691/commits","review_comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/6691/comments","review_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments{/number}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/6691/comments","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/53bbba8b8952d4a7be6d09a80a97c27e1730be2d","head":{"label":"code-dot-org:cdo-apps-refactor","ref":"cdo-apps-refactor","sha":"53bbba8b8952d4a7be6d09a80a97c27e1730be2d","user":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"repo":{"id":24250009,"name":"code-dot-org","full_name":"code-dot-org/code-dot-org","owner":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-dot-org/code-dot-org","description":"The code powering code.org and studio.code.org","fork":false,"url":"https://api.github.com/repos/code-dot-org/code-dot-org","forks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/forks","keys_url":"https://api.github.com/repos/code-dot-org/code-dot-org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-dot-org/code-dot-org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-dot-org/code-dot-org/teams","hooks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/hooks","issue_events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/events{/number}","events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/events","assignees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/assignees{/user}","branches_url":"https://api.github.com/repos/code-dot-org/code-dot-org/branches{/branch}","tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/tags","blobs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/{sha}","languages_url":"https://api.github.com/repos/code-dot-org/code-dot-org/languages","stargazers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/stargazers","contributors_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contributors","subscribers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscribers","subscription_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscription","commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/comments{/number}","contents_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contents/{+path}","compare_url":"https://api.github.com/repos/code-dot-org/code-dot-org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-dot-org/code-dot-org/merges","archive_url":"https://api.github.com/repos/code-dot-org/code-dot-org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-dot-org/code-dot-org/downloads","issues_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues{/number}","pulls_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls{/number}","milestones_url":"https://api.github.com/repos/code-dot-org/code-dot-org/milestones{/number}","notifications_url":"https://api.github.com/repos/code-dot-org/code-dot-org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-dot-org/code-dot-org/labels{/name}","releases_url":"https://api.github.com/repos/code-dot-org/code-dot-org/releases{/id}","deployments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/deployments","created_at":"2014-09-20T00:46:11Z","updated_at":"2016-01-27T16:50:58Z","pushed_at":"2016-02-06T03:22:12Z","git_url":"git://github.com/code-dot-org/code-dot-org.git","ssh_url":"git@github.com:code-dot-org/code-dot-org.git","clone_url":"https://github.com/code-dot-org/code-dot-org.git","svn_url":"https://github.com/code-dot-org/code-dot-org","homepage":"http://code.org","size":3965567,"stargazers_count":82,"watchers_count":82,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":46,"mirror_url":null,"open_issues_count":52,"forks":46,"open_issues":52,"watchers":82,"default_branch":"staging"}},"base":{"label":"code-dot-org:chef-12-client-support","ref":"chef-12-client-support","sha":"cf837f35baa22c45c2133b82c723ed98e34f56c3","user":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"repo":{"id":24250009,"name":"code-dot-org","full_name":"code-dot-org/code-dot-org","owner":{"login":"code-dot-org","id":5124627,"avatar_url":"https://avatars.githubusercontent.com/u/5124627?v=3","gravatar_id":"","url":"https://api.github.com/users/code-dot-org","html_url":"https://github.com/code-dot-org","followers_url":"https://api.github.com/users/code-dot-org/followers","following_url":"https://api.github.com/users/code-dot-org/following{/other_user}","gists_url":"https://api.github.com/users/code-dot-org/gists{/gist_id}","starred_url":"https://api.github.com/users/code-dot-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-dot-org/subscriptions","organizations_url":"https://api.github.com/users/code-dot-org/orgs","repos_url":"https://api.github.com/users/code-dot-org/repos","events_url":"https://api.github.com/users/code-dot-org/events{/privacy}","received_events_url":"https://api.github.com/users/code-dot-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/code-dot-org/code-dot-org","description":"The code powering code.org and studio.code.org","fork":false,"url":"https://api.github.com/repos/code-dot-org/code-dot-org","forks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/forks","keys_url":"https://api.github.com/repos/code-dot-org/code-dot-org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/code-dot-org/code-dot-org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/code-dot-org/code-dot-org/teams","hooks_url":"https://api.github.com/repos/code-dot-org/code-dot-org/hooks","issue_events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/events{/number}","events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/events","assignees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/assignees{/user}","branches_url":"https://api.github.com/repos/code-dot-org/code-dot-org/branches{/branch}","tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/tags","blobs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/refs{/sha}","trees_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/{sha}","languages_url":"https://api.github.com/repos/code-dot-org/code-dot-org/languages","stargazers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/stargazers","contributors_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contributors","subscribers_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscribers","subscription_url":"https://api.github.com/repos/code-dot-org/code-dot-org/subscription","commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/commits{/sha}","git_commits_url":"https://api.github.com/repos/code-dot-org/code-dot-org/git/commits{/sha}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/comments{/number}","issue_comment_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/comments{/number}","contents_url":"https://api.github.com/repos/code-dot-org/code-dot-org/contents/{+path}","compare_url":"https://api.github.com/repos/code-dot-org/code-dot-org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/code-dot-org/code-dot-org/merges","archive_url":"https://api.github.com/repos/code-dot-org/code-dot-org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/code-dot-org/code-dot-org/downloads","issues_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues{/number}","pulls_url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls{/number}","milestones_url":"https://api.github.com/repos/code-dot-org/code-dot-org/milestones{/number}","notifications_url":"https://api.github.com/repos/code-dot-org/code-dot-org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/code-dot-org/code-dot-org/labels{/name}","releases_url":"https://api.github.com/repos/code-dot-org/code-dot-org/releases{/id}","deployments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/deployments","created_at":"2014-09-20T00:46:11Z","updated_at":"2016-01-27T16:50:58Z","pushed_at":"2016-02-06T03:22:12Z","git_url":"git://github.com/code-dot-org/code-dot-org.git","ssh_url":"git@github.com:code-dot-org/code-dot-org.git","clone_url":"https://github.com/code-dot-org/code-dot-org.git","svn_url":"https://github.com/code-dot-org/code-dot-org","homepage":"http://code.org","size":3965567,"stargazers_count":82,"watchers_count":82,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":46,"mirror_url":null,"open_issues_count":52,"forks":46,"open_issues":52,"watchers":82,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/6691"},"html":{"href":"https://github.com/code-dot-org/code-dot-org/pull/6691"},"issue":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/6691"},"comments":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/6691/comments"},"review_comments":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/6691/comments"},"review_comment":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/6691/commits"},"statuses":{"href":"https://api.github.com/repos/code-dot-org/code-dot-org/statuses/53bbba8b8952d4a7be6d09a80a97c27e1730be2d"}}}}