Files
spinifex/config

Hive Systemd Service

This directory contains the systemd service configuration for running Hive services on Ubuntu and Debian systems.

Files

  • hive.service - The systemd service file that manages all Hive services
  • install-hive-service.sh - Installation script to set up the service
  • README.md - This documentation file

Installation

Prerequisites

  1. Ensure Hive is installed in /opt/hive/
  2. Ensure the hive binary is available at /opt/hive/bin/hive
  3. Run the installation script as root

Quick Installation

sudo ./config/install-hive-service.sh

Manual Installation

If you prefer to install manually:

  1. Copy the service file:

    sudo cp config/hive.service /etc/systemd/system/
    
  2. Reload systemd:

    sudo systemctl daemon-reload
    
  3. Enable the service:

    sudo systemctl enable hive.service
    

Service Management

Start the service

sudo systemctl start hive

Stop the service

sudo systemctl stop hive

Check service status

sudo systemctl status hive

Restart the service

sudo systemctl restart hive

View service logs

sudo journalctl -u hive -f

Disable auto-start

sudo systemctl disable hive

Service Details

The hive.service file:

  • Starts services in the correct order: NATS → Predastore → Viperblock
  • Includes proper delays between service starts to ensure dependencies are ready
  • Stops services in reverse order during shutdown
  • Runs as root (required for system services)
  • Includes security hardening settings
  • Provides proper logging to systemd journal
  • Automatically restarts on failure

Service Order

The service starts the following components in order:

  1. NATS - Message broker service
  2. Predastore - Data storage service (waits 3 seconds after NATS)
  3. Viperblock - Block storage service (waits 2 seconds after Predastore)

Troubleshooting

Check if the service is running

sudo systemctl is-active hive

View recent logs

sudo journalctl -u hive --since "1 hour ago"

Check service configuration

sudo systemctl cat hive

Verify binary exists

ls -la /opt/hive/bin/hive

Test service commands manually

/opt/hive/bin/hive service nats start
/opt/hive/bin/hive service predastore start
/opt/hive/bin/hive service viperblock start

Customization

If you need to modify the service configuration:

  1. Edit the service file: sudo nano /etc/systemd/system/hive.service
  2. Reload systemd: sudo systemctl daemon-reload
  3. Restart the service: sudo systemctl restart hive

Security Notes

  • The service runs as root, which is necessary for system-level services
  • Security hardening is enabled with ProtectSystem=strict and NoNewPrivileges=true
  • Only specific paths are writable: /opt/hive, /var/log, /var/run