The RunCloud Service Checker is a Python script designed to prevent service interruptions on RunCloud servers caused by out-of-memory (OOM) events. This script monitors the status of server services and automatically restarts them if necessary.
- Check the status of specified services.
- Automatically restart services if they are not running.
- Email notifications for service restarts.
These instructions will help you get the project up and running on your local machine or server.
Before you begin, make sure you have Python 3.x installed along with the python-dotenv
package, which is required for loading configuration settings from the .env
file. If you don't have Python and python-dotenv
installed, follow the instructions below:
-
Python 3 Installation:
- Instructions for installing Python 3 vary by platform. Please refer to the Python 3 installation guide for your operating system.
-
Installing python-dotenv:
- Once Python 3 is installed, open your terminal or command prompt and install the
python-dotenv
package using pip:pip install python-dotenv
- Once Python 3 is installed, open your terminal or command prompt and install the
- Clone the repository to your local machine:
git clone https://github.com/fabiomsnunes/runcloud-service-checker.git
- Navigate to the project directory:
cd runcloud-service-checker
To set up the project, you will start by renaming the .env.example
file to .env
. Inside this .env
file, you'll find placeholders for various settings that need to be configured:
-
RunCloud API Secrets: These are your personal credentials for accessing the RunCloud API, including your API Key (
API_KEY
) and API Secret (API_SECRET
). You will need to replace the placeholders with your actual RunCloud API credentials. -
Services to Check: Specify which services the script should monitor on your RunCloud servers. This is done by listing the service names under
SERVICES_TO_CHECK
, separated by commas. -
SMTP Details: For the script to send email notifications, you must provide SMTP server details, including the host (
SMTP_HOST
), port (SMTP_PORT
), username (SMTP_USERNAME
), and password (SMTP_PASSWORD
).
Ensure that you carefully replace the placeholder values with your actual configuration details to ensure the script functions correctly.
Run the script using Python:
python runcloud-service-checker.py
You can also use the --verbose
flag to display detailed output:
python runcloud-service-checker.py --verbose
To automate the service checking process, you can set up a cron job to run the script at specified intervals. Here's an example of how to do it:
- Open your crontab configuration for editing:
crontab -e
- Add a new line to schedule the script to run at your preferred frequency. For example, to run the script every 5 minutes, add the following line:
*/5 * * * * /usr/bin/python3 /path/to/runcloud-service-checker/check.py
Make sure to replace /usr/bin/python3
with the path to your Python 3 interpreter, and /path/to/runcloud-service-checker
with the actual path to the script's directory.
- Save and exit the text editor. The script will now run automatically according to your cron job schedule.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the RunCloud team for providing the API and services for this script.
Contributions are welcome! Please feel free to open an issue or create a pull request.
For questions or feedback, you can contact the author:
- Fábio Nunes
- GitHub: https://github.com/fabiomsnunes