To avoid the one-hour time limit on your dyno, use this npm module:
require('heroku-self-ping')("http://your-app-url");
This will register a timer self-pinging your app every 45 minutes.
This timer will only activate when your app is running on Heroku platform. The script is a no-op on any other environment, including local and CI.
your-app-url
can be any URL to access your app -- anherokuapp.com
subdomain or any custom domain defined with your app.
Heroku doesn't allow an app to retrieve its current name, which is why you need to manually specify the URL.
options
, optional object with the following keys:interval
number of ms between two heartbeats calls. Default to45 * 60 * 1000
(45 minutes).logger
function to use for logging. Default toconsole.log
verbose
send more information to logger function. Default tofalse
.
The function returns an interval id when running on Heroku and the URL is not falsy, and false
in other cases.
We recommend you set a custom env variable, for instance heroku config:set APP_URL http://yourapp.herokuapp.com
and access it later from process.env.APP_URL
.
The lib won't do anything when passed an empty url
.