Skip to content

Instantly share code, notes, and snippets.

@keidrun
Created April 17, 2018 23:10
Show Gist options
  • Save keidrun/bd9913901e8eeb9acbd4cd64f2922bb1 to your computer and use it in GitHub Desktop.
Save keidrun/bd9913901e8eeb9acbd4cd64f2922bb1 to your computer and use it in GitHub Desktop.
Simple Clock process as Docker container to prevent idling for free dyno on Heroku
const http = require('http');
const ACCESS_URL = 'http://my-herokuapp.herokuapp.com';
const INTERVAL_MSEC = 10 * 60 * 1000; // every 10 minutes
setInterval(() => {
http
.get(ACCESS_URL, res => {
console.log(res.statusCode, res.statusMessage, ACCESS_URL);
})
.on('error', err => {
console.log(err, ACCESS_URL);
});
}, INTERVAL_MSEC);
FROM node:9.11.1-alpine
LABEL maintainer="Keid"
RUN mkdir /app
WORKDIR /app
COPY clock.js clock.js
CMD node clock.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment