Have you tried turning it off and on again? Offline Server Auto Restart uses a Raspberry Pi and Tapo P100 (or P105) smart plug to automatically power cycle a server that unexpectedly went down.
- Tapo P100 or P105 smart plug connected to your server as well as to your network
- Node.js and npm installed
- Any open port on the server (could be SSH, HTTP, etc.)
- Raspberry Pi or similar second computer that is always on and connected to the same network as the smart plug and server
- BIOS settings configured to turn on the server when power is restored (not absolutely necessary as Wake-on-LAN is used, but it's a good failsafe)
- Clone this repository to your Raspberry Pi
- Run
npm install
to install dependencies - Copy
.env.example
to.env
and fill in the required values - Run
node get_device_id.mjs
to get the device ID of your smart plug - Copy the device ID to the
.env
file - Run
node index.mjs
to start the script. Preferably, use a process manager like PM2 to keep the script running in the background and to automatically restart it if it crashes.
Some servers respond to ping requests even if they are turned off (for example, devices with Intel AMT configured or servers with Wake-on-LAN enabled). This script checks the ports to see if the server is running.
- There is a chance that the checked port will be closed during a graceful shutdown or reboot. In that case, the script will assume that the server is down and will power cycle it. This could result in data loss.
- Servers rebooting into the BIOS or UEFI setup will not be detected as running and will be power cycled.