{"action":"created","issue":{"url":"https://api.github.com/repos/rschmukler/agenda/issues/131","labels_url":"https://api.github.com/repos/rschmukler/agenda/issues/131/labels{/name}","comments_url":"https://api.github.com/repos/rschmukler/agenda/issues/131/comments","events_url":"https://api.github.com/repos/rschmukler/agenda/issues/131/events","html_url":"https://github.com/rschmukler/agenda/issues/131","id":53223147,"number":131,"title":"Restarting the server may stop the recurring jobs forever","user":{"login":"abdelhady","id":2075626,"avatar_url":"https://avatars.githubusercontent.com/u/2075626?v=3","gravatar_id":"","url":"https://api.github.com/users/abdelhady","html_url":"https://github.com/abdelhady","followers_url":"https://api.github.com/users/abdelhady/followers","following_url":"https://api.github.com/users/abdelhady/following{/other_user}","gists_url":"https://api.github.com/users/abdelhady/gists{/gist_id}","starred_url":"https://api.github.com/users/abdelhady/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abdelhady/subscriptions","organizations_url":"https://api.github.com/users/abdelhady/orgs","repos_url":"https://api.github.com/users/abdelhady/repos","events_url":"https://api.github.com/users/abdelhady/events{/privacy}","received_events_url":"https://api.github.com/users/abdelhady/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-01-01T16:31:39Z","updated_at":"2015-02-04T22:13:30Z","closed_at":null,"body":"I'm starting my job every 30 minutes, but sometimes when restarting the server, the job stops working forever until I remove it from the `agendaJobs` collection manually, & I tried smaller periods for testing like 10 seconds, & it is now a consistent behavior, my code is like this:\r\n````coffeescript\r\nagenda.start()\r\ngraceful = ()->\r\n\tagenda.stop ()->\r\n\t\tprocess.exit 0\r\n\r\nprocess.on 'SIGTERM', graceful\r\nprocess.on 'SIGINT' , graceful\r\n\r\nagenda.define 'my job', my_job_function\r\nagenda.every '10 seconds', 'my job'\r\n\r\n````\r\n\r\nAnd as a workaround, I decided to cancel all recurring jobs when stopping the server like this:\r\n````coffeescript\r\ngraceful = ()->\r\n\tagenda.cancel repeatInterval: { $exists: true, $ne: null }, (err, numRemoved)->\r\n\t\tagenda.stop ()->\r\n\t\t\tprocess.exit 0\r\n````\r\nWith this workaround, now restarting the server doesn't affect any of the recurring jobs,\r\n\r\n**but, I don't know why I have to cancel all the recurring jobs in order to be safe from such a situation?!**"},"comment":{"url":"https://api.github.com/repos/rschmukler/agenda/issues/comments/72951261","html_url":"https://github.com/rschmukler/agenda/issues/131#issuecomment-72951261","issue_url":"https://api.github.com/repos/rschmukler/agenda/issues/131","id":72951261,"user":{"login":"BlakePetersen","id":1954308,"avatar_url":"https://avatars.githubusercontent.com/u/1954308?v=3","gravatar_id":"","url":"https://api.github.com/users/BlakePetersen","html_url":"https://github.com/BlakePetersen","followers_url":"https://api.github.com/users/BlakePetersen/followers","following_url":"https://api.github.com/users/BlakePetersen/following{/other_user}","gists_url":"https://api.github.com/users/BlakePetersen/gists{/gist_id}","starred_url":"https://api.github.com/users/BlakePetersen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlakePetersen/subscriptions","organizations_url":"https://api.github.com/users/BlakePetersen/orgs","repos_url":"https://api.github.com/users/BlakePetersen/repos","events_url":"https://api.github.com/users/BlakePetersen/events{/privacy}","received_events_url":"https://api.github.com/users/BlakePetersen/received_events","type":"User","site_admin":false},"created_at":"2015-02-04T22:13:30Z","updated_at":"2015-02-04T22:13:30Z","body":"Haven't found time to investigate all that's going on, but for what it's worth, using the worker approach with forever -w to restart server on changes appears to be working perfectly for me."}}