I want to add scheduled jobs in Openshift, which would be getting added dynamically to my application. I had tried the cron service on Openshift, but it stops after certain amount of time. I want to add a service similar to Iron workers or heroku workers, but these services seem to be costly. Also is it possible to implement such a service on our own in Openshift?
First off, I'm guessing your Cron service is stopping when your application idles. Idling occurs when your app doesn't receive web traffic for 24 hours. Just upgrade to the Bronze plan to remove idling (it's free).
Second off, you can add IronWorker as an Add-on Service through the OpenShift Marketplace: https://hub.openshift.com/addons/10-ironworker
If you're using Ruby you could also just run Resque with Redque Scheduler along with the downloadable Redis cartridge:
Resque/Resque Scheduler: https://github.com/resque
Redis: https://hub.openshift.com/addons/34-redis
Related
I am running a web application on heroku.
I have a couple cron jobs running on my server at 9am, 12pm, and 12am.
I need my web page to not have idled for me to run these cron jobs. As such I need some way to ping the web page just before these times to make sure it is running so that these cron jobs can be executed. I've seen uptime robot and new relic but they seem to only ping all the time for set intervals whereas I want to ping my webpage at specific times.
You can do one of two things:
Use the Heroku Scheduler addon to ping your dyno by making a request to it before the time you need your dyno to be awake, OR
You can pay for a normal dyno. Heroku doesn't idle the normal dynos, only the free ones.
You could configure a Heroku Scheduler to run and to wake up your web dyno by pinging it just before the time you need your web dyno to wake up.
If I have an app on Heroku that consists of one worker and one or no web dynos, will it run? I'm unsure if the absent or idling web dynos will cause the worker dyno not to run.
Heroku doesn't just run web dynos, in fact, it makes no assumptions at all with regards to the processes you're running. There's absolutely nothing wrong with launching a single worker process.
This is actually a common scenario for me to deploy single cron-like tasks to Heroku, I've written about it here http://blog.y3xz.com/blog/2012/11/16/deploying-periodical-tasks-on-heroku/
If you are looking for cron-like tasks for simple jobs (like I am), now you have another alternative: Heroku Scheduler. It is easy to configure in a dashboard.
Advantage:
No need to choose and learn a new scheduler library. Configure it in seconds.
Same way for different platforms: Python, Ruby, etc.
Save Dyno Hours for Free Plan user. Only the actual working time counts. Some scheduler library (like Rufus Scheduler) will keep running between launches (so that it does not rely on cron to work).
Disadvantage:
Trivial options. You can only choose among "Daily"/"Hourly"/"Every 10 minutes".
Conclusion: Best for basic use.
I've created an Azure Worker Role running node.js using the Windows Azure PowerShell. I've successfully deployed my service and am wondering if the Worker Role will restart the process if it were to die. Is that a benefit of using a Web Role and iisnode over a Worker Role?
Update
I made a quick test as Golo Roden suggested in his answer and confirmed that an Azure Worker Role does restart the node process if it dies.
To be true, I don't know.
But it should be very simple to find out: Just write a simple Node.js application that does nothing but react on requests in a simple form and shuts itself down after 60 seconds or so using setTimeout and process.exit();.
Then deploy it, test it, wait a few minutes, and if it still does work, obviously Azure restarts the process.
PS: It would be awesome if you could post your findings here.
Is there a way to get a scheduled job to run on a single server? We have an email sending job that I don't want running twice simultaneously. Is this what heroku workers are for? I am currently under the impression that play! jobs actually run on web workers. Thanks!
We've been using Play! (not on Heroku) and found the easiest way was to define a framework id for the servers you want to run the jobs, and a framework id for the servers that won't run the jobs.
In our case, "prodapp" are the Production Application servers that don't run jobs, and "prodadmin" is the Production Admin/Job server (only one).
We've included the following in our application.conf to disable the jobs plugin on the prodapp servers:
%prodapp.plugins.disable=play.jobs.JobsPlugin
I'm not sure it's the best solution, but after investigating some other options, we determined it to be the quickest to implement without forking the Play! source code.
I sent a support ticket to Heroku for the same query. They advised not to use Play scheduled jobs, but to instead use the Scheduler add-on instead.
I don't think you can specify a server id within Heroku, so you cannot distinguish one web server from another, and therefore cannot only use one instance for jobs like you could if you had control over the number of servers you were spinning up.
I've got an Express Web app running as my main app on Heroku Cedar. I need to run a worker job periodically. I know I can specify a worker: in my Procfile, but that seems to be for a forever running kind of job. Perhaps there is a way to have the event mechanism of nodeJS caus e the worker to Idle, and use Cron to poke it alive periodically??
to keep your process alive you can try using an external service which will "ping" your application, you can use the newrelice free addon on heroku for that.
I am currently experimenting and it seems that even with this the application is still put in idle mode but it restarts on the next "ping" so it is still up most of the time.
I don't known node.js but I do my worker with Ruby+EventMachine inside a ruby on rails application and it works fine, you just need something to work in the background aside of your web requests.