Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luqmanoop/pingmydyno
Keep Heroku dynos awake forever ☕️
https://github.com/luqmanoop/pingmydyno
dyno heroku nodejs ping typescript
Last synced: 3 months ago
JSON representation
Keep Heroku dynos awake forever ☕️
- Host: GitHub
- URL: https://github.com/luqmanoop/pingmydyno
- Owner: luqmanoop
- License: mit
- Created: 2019-03-26T07:43:28.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T18:36:42.000Z (about 2 years ago)
- Last Synced: 2024-11-07T09:28:38.359Z (3 months ago)
- Topics: dyno, heroku, nodejs, ping, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/pingmydyno
- Size: 1.66 MB
- Stars: 25
- Watchers: 1
- Forks: 1
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
## Why?
Heroku (free) dynos are great for hosting apps and showing them off to
your boss/friends or potential employer. The downside, however, is that your app
will fall asleep 😴 if it doesn't receive any web traffic within a 30-minute
window.`pingmydyno` solves this by pinging your server periodically so it never falls asleep.
## Features
- Forever dyno pings
- Automatically retry ping on failure## Installation
```bash
npm install pingmydyno# or using yarn
yarn add pingmydyno
```## Usage
With Express.js (ES6 module)
```javascript
...
import express from 'express';
import pingmydyno from 'pingmydyno';const app = express();
...
app.listen(PORT, () => {
pingmydyno('https://myapp.herokuapp.com');
});```
With Hapi.js (commonJS)
```javascript
const Hapi = require('hapi');
const pingmydyno = require('pingmydyno');const server = Hapi.server({ port, host });
async () => {
await server.start();
pingmydyno('https://myapp.herokuapp.com');
};
```With Koa.js
```javascript
const Koa = require('koa');
const pingmydyno = require('pingmydyno');const app = new Koa();
const url = process.env.APP_URL;...
app.listen(3000).on('listening', () => {
pingmydyno(url, {
pingInterval: 60 * 15 * 1000, // ping every 15mins
onFailure() {
// logger
}
})
})
```## APIs
**pingmydyno(url, [Config])**
### url
Type: `string`
Required: `yes`
### Config
Type: `Object`
Required: `no`
| | value | default | description |
| ------------ | --------------------- | ----------- | ---------------------------------------------------- |
| pingInterval | number (milliseconds) | 1200000 | interval between the next ping (max = 25mins) |
| maxRetry | number | 2 | retry times when ping fail |
| onSuccess | function | ( ) => null | callback function called when a ping is successful |
| onFailure | function | ( ) => null | callback function called when `maxRetry` ping failed |## Contributors
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Kizito Akhilome
💻
Luqman Olushi O.
🐛 💻 📖 🚧This project follows the
[all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!## License
This project is license under
[MIT](https://github.com/codeshifu/pingmydyno/blob/master/LICENSE)