akiva
akiva

Reputation: 2737

openshift application goes idle and halts its cron jobs

I use openshift to run a script from time to time with the cron cartridge. however, as my application has no web activity (yet) it goes idle and my process doesn't run.

one could think of an ugly solution to generate fake web-load by using another service (such as ifttt to retrieve a page constantly but this sounds wrong.

could there be a better solution?

Upvotes: 15

Views: 5349

Answers (6)

Aaron Burke
Aaron Burke

Reputation: 21

Bronze is free. All plans retain the free stuff, e.g. 3 free gears etc. you will only pay $0.02 hr on gears above 3. So if you are using the free tear and not using 3 gears you should be safe to upgrade to bronze and remain free.

Upvotes: 2

Javid Abdul Razack
Javid Abdul Razack

Reputation: 37

Openshift cartridge goes idle after 24 hours of inactivity.

Activity is considered receiving a Get request in your application originated outside your cartridge (so pinging your app from your own cartridge doesn’t work).

You can use any free pinging service to ping your application after a specific interval of time(< 24hrs).

You may use Pingdom. I have found success using it. It provides a nice dashboard and graphs of response time as well. You will be notified if there is any issues connecting to your app or if its down. You can manage your account with their mobile apps.

There are other free pinging services too. Feel free to Google and try out other services. Do comment if you find a good one, might be a great help for some :-).

Upvotes: 3

Marcello Kad
Marcello Kad

Reputation: 198

In your nodejs app:

  1. Create an httpserver able to dispatch a get request page
  2. Include a cron job into your array job list that every hour send a post to external page (php,jsp or every kind of "page" that can create a curl request).

In external page:

  1. Execute the logic of a job (optional because you can use job2, job3..jobn and leave this job just for hold your app awake)
  2. Insert somewhere in the code a request back to nodejs server page using php curl library.

In this case:

  1. At every hour, idle timeout will be reset and your application stay awake
  2. You can decide to put jobs in external pages and/or nodejs

Hope it helps someone.

EDIT: I'm sorry, it's not working anymore. No matter which kind of strategy you use, they will be able to discover systematic requests coming from a specific IP and exclude this situation, bringing your app idle for earn money, because everybody know that BRONZE is not FREE. It costs at least 0.02$/hour.

Upvotes: 0

mxxk
mxxk

Reputation: 10234

OpenShift will idle your application after 24 hours of inactivity1, but you can add an hourly cron job to your app to keep itself alive.

.openshift/cron/hourly/ping.sh

#!/bin/bash

PATH=/bin:/usr/bin:/usr/sbin
app_url=http://$OPENSHIFT_APP_DNS/

curl --insecure --location --silent --fail "$app_url" >/dev/null

Assuming your app isn't already idled and won't run the cron job :-)


1 Apparently the idle period used to be 48 hours before, but now it is 24 hours according to the OpenShift pricing table. In other words, a daily pinger cron job won't do it for you.

OpenShift Pricing Chart—Free gears get idled after 24 hours of inactivity

Upvotes: 4

user2879327
user2879327

Reputation:

It's not really a "trick" per se, but as long as you have consistent incoming traffic, your gear will not idle.

Upvotes: 2

akiva
akiva

Reputation: 2737

apparently the only way is to trick openshift to have out-coming traffic, I used a free account of https://www.site24x7.com for that

Upvotes: 8

Related Questions