1.0.5 • Published 2 years ago

autokills v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

AutoKills

Discord Server NPM Version NPM Downloads

The autokills library provides the AutoKill class that allows you to automatically restart a Node.js process after a certain time interval if the process becomes unresponsive or loses connection.

Usage

To use this library, you need to import the AutoKill class from the module and create an instance of the class, passing in the client object and the time interval for automatic restart in milliseconds.

const { AutoKill } = require('autokills');

const client = new MyClient();
const time = 60000; // 1 minute

const autoKill = new AutoKill(client, time);

autoKill.start();

Methods

The AutoKill class represents a tool for automatically terminating the application process, for example, in case of a lost connection to the server.

The methods of the class include:

  • constructor(client, time): class constructor, takes the client object and the time number. Throws errors if the client is not passed, the time is less than 5 seconds, or not specified at all.

  • restart(): stops and restarts the timer.

  • onKill(callback): sets a callback function when the process is killed.

  • start(): starts the timer, which will call the callback function if the client is not ready or not received.

  • stop(): stops the timer.

  • getTimeRemaining(): calculates the remaining time of the timer.

  • pause(): stops the timer, but does not kill the process.

  • resume(): resumes the timer.

  • isRunning(): returns true if the timer is running, and false otherwise.

  • onPause(callback): sets a callback function when the timer is paused.

  • onResume(callback): sets a callback function when the timer is resumed.

  • setTime(time): sets a new time value for the timer.

  • onRestart(callback): sets a callback function when the timer is restarted.

  • onStop(callback): sets a callback function when the timer is stopped.

  • onStart(callback): sets a callback function when the timer is started.

  • setClient(client): sets a new client.

  • setKillTime(time): sets a new time value for the timer and restarts it.

  • checkConnection(): checks if the client is connected to the server and restarts the timer if the connection was lost.

Documentation

Detailed documentation on autokills can be found on the official website.

Contribution

We welcome your contributions to the development of autokills! If you have any ideas or suggestions, please visit the Official Support Server.

License

Autokills is available under the MIT license. For more information, see the LICENSE file.

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago