Skip to main content

Manage servers by rebooting using BCM in case of crashes.

Project description

Starlyng Smart Reboot

This project manages servers by automatically rebooting them using Baseboard Management Controller (BCM) when crashes occur.

Prerequisites

Before you begin, ensure you have met the following requirements:

  • Python 3.x installed
  • Basic understanding of Python and virtual environments
  • ipmitool installed on the server you will run the script:
    • Ubuntu: sudo apt-get install ipmitool
    • macOS: brew install ipmitool
  • If outside local network, configure port forwarding on your router:
    • Forward BCM port 623 to each server's unique port (62300-62399)
    • Example: Forward port 62300 to 192.168.50.13:623, port 62301 to 192.168.50.14:623
    • Port range must be between 62300-62399

Running

Using VSCode/Cursor

Run the Program:

  • Go to the Run and Debug view (⌘+Shift+D, or Ctrl+Shift+D on Windows)
  • Select the pre-configured launch configuration from the dropdown menu
  • Click the green play button (F5) or use the "Run" menu to start the program

Setting Up Your Development Environment

  1. Clone the repository:

    git clone https://github.com/starlyngapp/smart-reboot.git
    cd smart-reboot
    
  2. Setup Environment for VSCode:

  • Open the Command Palette (Ctrl+Shift+P)
  • Search for the Python: Create Environment command, and select it
  • Select Venv
  • Select Python interpreter
  • Select dependencies to install
  1. Install Required Packages

Install all dependencies listed in the dev-requirements.txt file:

pip install -r dev-requirements.txt

Installation

To install only the package (without dev dependencies):

pip install starlyng_smart_reboot

To install development dependencies (useful for contributing to the project):

pip install starlyng_smart_reboot[dev]

Alternatively, you can install the development dependencies using:

pip install -r dev-requirements.txt

Create and activate a virtual environment:

  • macOS/Linux:
    python -m venv venv
    source venv/bin/activate
    
  • Windows:
    python -m venv venv
    venv\Scripts\activate
    

Releases to PyPi

This should be done through creating a new release in GitHub

Environment Configuration

To configure smart reboot, you need to set up environment variables. This can be done by creating a .env file in the root of the project.

An example .env file is provided as .env.example. You can copy this file and update the values as needed.

Steps to Configure Environment Variables

  1. Copy the example environment file:
cp .env.example .env
  1. Open the .env file and update the values:
# .env
# List of server IPs and ports in the format ip:port, separated by commas
BCM_SERVERS=192.168.1.1:623,192.168.1.2:623

# BCM username
BCM_USER=user

# BCM password
BCM_PASSWORD=secret
  1. Save the .env file.

The BCM_SERVERS variable should be a comma-separated list of server IP addresses and ports.

Usage

To run the main function:

smart_reboot

PyPI

starlyng-smart-reboot

Command-line Arguments

You can also override configuration using command-line arguments:

smart_reboot --bcm_servers "192.168.1.1:623,192.168.1.2:623" --bcm_user "bcm_username" --bcm_pass "secret" --public_ip "false" --server_mgmt_dir "/path/to/server/mgmt/" --ssh_base_hostname "server" --ssh_key_path "/path/to/your/.ssh/id_rsa" --ssh_user "your_ssh_username" --ssh_vlan_id "10" --vast_api_key "vast_api_key"

Or locally:

python main.py --bcm_servers "192.168.1.1:623,192.168.1.2:623" --bcm_user "bcm_username" --bcm_pass "secret" --public_ip "false" --server_mgmt_dir "/path/to/server/mgmt/" --ssh_base_hostname "server" --ssh_key_path "/path/to/your/.ssh/id_rsa" --ssh_user "your_ssh_username" --ssh_vlan_id "10" --vast_api_key "vast_api_key"

Building and Uploading Your Package

  1. Build the package:
python setup.py sdist bdist_wheel
  1. Upload to PyPI:
twine upload dist/*

Upload using specific project name referenced in .pypirc

twine upload dist/* --repository starlyng-smart-reboot

Running Tests

To run tests, execute the following command in your terminal:

pytest

This command will run all tests and report the results. You can also run specific tests by providing the path and filename of the test file.

Contributing to the Project

Contributions to this project are welcome. Here's how you can contribute:

  1. Fork the project.
  2. Create your feature branch (git checkout -b feature/YourFeature).
  3. Commit your changes (git commit -am 'Add some YourFeature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a pull request.

Contact

If you have any questions, please contact:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starlyng_smart_reboot-0.2.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

starlyng_smart_reboot-0.2.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file starlyng_smart_reboot-0.2.1.tar.gz.

File metadata

  • Download URL: starlyng_smart_reboot-0.2.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.20

File hashes

Hashes for starlyng_smart_reboot-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d1275ab1ead7f68729f6d9382fe86670e10c7f90366ff2e2d2b8187612b5785b
MD5 3fb55c18f2d5e111ba295678acf0a1f5
BLAKE2b-256 b941f61cedec27a289b5058ccbf66cf2aaa9d85d1946f1fdb4431c2eaa475b24

See more details on using hashes here.

File details

Details for the file starlyng_smart_reboot-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for starlyng_smart_reboot-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f296952a4258041a8c05511a17cb155c9e9fe8514aa55772cf20fbd2947b799
MD5 d0881d2174c39f035c76021d1cc40f08
BLAKE2b-256 b7afe65937d328d1abe43ce100c144ee5c9ed4adcd3b486ba888def7d2cac674

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page