https://github.com/reinskywalker/node-pinger
Dead simple stuff to ping a URL on a loop, with logging and retry support, none fancy. Useful for keeping services awake or checking if something's still alive.
https://github.com/reinskywalker/node-pinger
Last synced: 11 months ago
JSON representation
Dead simple stuff to ping a URL on a loop, with logging and retry support, none fancy. Useful for keeping services awake or checking if something's still alive.
- Host: GitHub
- URL: https://github.com/reinskywalker/node-pinger
- Owner: reinskywalker
- Created: 2025-07-09T08:09:00.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-09T12:45:50.000Z (11 months ago)
- Last Synced: 2025-07-09T13:52:41.984Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Node Pinger
Node.js script to ping a specific URL at defined intervals with optional retry and logging.
## Features
- Ping any HTTP/HTTPS endpoint repeatedly
- Control request interval and total duration
- Retry failed requests with delay
- Log results to timestamped files
- No external dependencies except `axios`
## Requirements
- Node.js 14+
## Installation
```bash
git clone https://github.com/reinskywalker/node-pinger.git
cd node-pinger
npm install
````
## Usage
Run the pinger with arguments:
```bash
npm run ping -- --url="https://example.com" --interval=10 --duration=0 --retries=3 --retryDelay=5 --expectStatus=200 --log=true
```
## Arguments
| Flag | Description |
| ---------------- | ---------------------------------------------------------------- |
| `--url` | Target URL to ping (required) |
| `--interval` | Delay between requests (in seconds) |
| `--duration` | How long to keep pinging (in seconds). Use `0` to run forever |
| `--retries` | Number of times to retry a failed request or non-matching status |
| `--retryDelay` | Delay between retries (in seconds) |
| `--expectStatus` | Expected HTTP status code (e.g. `200`) |
| `--log` | Whether to write output to log file (`true` or `false`) |
## Output
* Console will show timestamped result of each request
* If logging is enabled, log file is saved under `src/logs/` with format:
```
YYYY-MM-DD_01.log
YYYY-MM-DD_02.log
```
Each run will generate a new log file with incremented index in src\logs.
## Example
```bash
npm run ping -- --url="https://reynaldi.dev/" --interval=10 --duration=0 --retries=3 --retryDelay=5 --expectStatus=200 --log=true
```