Created
April 17, 2018 09:17
-
-
Save keidrun/71aa61db28d8c17d992aad50ae8a563f to your computer and use it in GitHub Desktop.
Clock process as Docker container to prevent idling for free dyno on Heroku
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const axios = require('axios'); | |
| const HEROKU_APP = 'my-herokuapp'; | |
| const INTERVAL_MSEC = 10 * 60 * 1000; // every 10 minutes | |
| setInterval(async () => { | |
| try { | |
| const response = await axios.get(`http://${HEROKU_APP}.herokuapp.com`); | |
| console.log(response.status, heroku_app); | |
| } catch (error) { | |
| console.log(error.response.status, heroku_app); | |
| } | |
| }, INTERVAL_MSEC); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:9.11.1-alpine | |
| LABEL maintainer="Keid" | |
| RUN mkdir /app | |
| WORKDIR /app | |
| RUN npm install -g [email protected] | |
| RUN chmod +x /usr/local/bin/yarn | |
| COPY package.json package.json | |
| COPY yarn.lock yarn.lock | |
| RUN yarn install \ | |
| && mv node_modules /node_modules | |
| 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