Reputation: 964
So I've just pushed my twitter bot to Heroku, and set to run every hour on the half hour with the Heroku scheduler addon. However, for whatever reason it's running every 10 minutes instead. Is this a bug with the scheduler? Here's an excerpt of my logs from when the scheduler ran it successfully and then it tried to run it again ten minutes later:
2013-01-30T19:30:20+00:00 heroku[scheduler.4875]: Starting process with command `python ff7ebooks.py`
2013-01-30T19:30:21+00:00 heroku[scheduler.4875]: State changed from starting to up
2013-01-30T19:30:24+00:00 heroku[scheduler.4875]: Process exited with status 0
2013-01-30T19:30:24+00:00 heroku[scheduler.4875]: State changed from up to complete
2013-01-30T19:34:34+00:00 heroku[web.1]: State changed from crashed to starting
2013-01-30T19:34:42+00:00 heroku[web.1]: Starting process with command `python ff7ebooks.py`
2013-01-30T19:34:44+00:00 heroku[web.1]: Process exited with status 0
2013-01-30T19:34:44+00:00 heroku[web.1]: State changed from starting to crashed
I can provide whatever info anyone needs to help me diagnose this issue.The [web.1] log messages repeat every couple of minutes. I don't want to spam my followers.
Upvotes: 1
Views: 2397
Reputation: 1
Fixed this problem by only one action at the end:
Upvotes: 0
Reputation: 194
I would share with you the solution of a guy that have helped me with a one-off running script (like a python script that starts and then ends, and not keeps running).
Any question let me know, and I will help you --> andreabalbo.com
Hi Andrea
I have also just created a random process-type in my Procfile:
tmp-process-type: command:test
I did not toggle on the process-type in the Heroku Dashboard. After installing the Advanced Scheduler, I creating a trigger with command "tmp-process-type" that runs every minute. Looking at my logs I can see that every minute a process started with "command:test", confirming that the process-type in the Procfile is working. I then toggled on the process-type in the Heroku Dashboard. This showed up immediately in my logs:
Scaled to tmp-process-type@1:Free web@0:Free by user ...
This is because after toggling, Heroku will spin up a normal dyno that it will try to keep up. Since your script is a task that ends, the dyno dies and Heroku will automatically restart it, causing your task to be run multiple times.
In summary, the following steps should solve your problem: 1. Toggle your process-type off (but leave it in the Procfile) 2. Install advanced-scheduler 3. Create a trigger (recurring or one-off) with command "tmp-process-type" 4. Look at your logs to see if anything weird shows up
With kind regards, Oscar
Upvotes: 0
Reputation: 964
If anyone else has this issue, I figured it out. I enabled the scheduler and then allocated 0 dynos, that way it only allocates a Heroku dyno when it is scheduled to run. For some reason it was running my process continuously and (my assumption is that) Twitter only let it connect to a socket every few minutes which resulted in the sporadic tweeting.
Upvotes: 7