Running Hive Link (macOS/Linux)

For reliable, long-running operation on macOS and Linux, run Hive Link under a process manager like pm2. This keeps it alive, restarts on failure, and enables auto-start on boot.

1) Install Node.js and pm2

Ensure Node.js is installed, then install pm2 globally:

# macOS (Homebrew) – optional if Node.js already installed
brew install node

# macOS & Linux – install pm2
npm install -g pm2

2) Place the Hive Link binary

Extract the download and make the binary executable. Keep it in a fixed location or move it to a directory on your PATH:

# Example: keep in a dedicated folder
mkdir -p ~/hive-link && mv ~/Downloads/hive-link ~/hive-link/
chmod +x ~/hive-link/hive-link

# Optional: move to a PATH directory (may require sudo)
sudo mv ~/hive-link/hive-link /usr/local/bin/hive-link

3) Start with pm2

Start Hive Link under pm2. Replace the path with where your binary lives. If you need environment variables, prefer an ecosystem file (next section).

# Path-based start
pm2 start /usr/local/bin/hive-link --name hive-link

# Or, if it's already on PATH
pm2 start hive-link --name hive-link

# View status and logs
pm2 ls
pm2 logs hive-link

Optional: use an ecosystem file

Manage paths and environment variables cleanly with an ecosystem file. Create ~/ecosystem.config.js (adjust values as needed):

cat > ~/ecosystem.config.js <<'EOF'
module.exports = {
  apps: [
    {
      name: 'hive-link',
      script: '/usr/local/bin/hive-link',
      env: {
        // Example variables – set as needed
        // HIVE_API_URL: 'https://api.printhive.app/v1',
        // HL_ORG_ID: 'org_xxx',
        // HL_ACCESS_TOKEN: '...'
      },
      watch: false,
      max_restarts: 10,
      restart_delay: 2000,
    },
  ],
};
EOF

pm2 start ~/ecosystem.config.js
pm2 save

4) Enable auto-start on boot

Configure pm2 to launch Hive Link automatically when your machine boots:

# macOS (launchd)
pm2 startup launchd

# Linux (systemd)
pm2 startup systemd -u $USER --hp $HOME

# pm2 will print a command; run that command, then save your process list
pm2 save

Verify after reboot:

pm2 ls
pm2 logs hive-link

Common operations

# Restart after updating the binary
pm2 restart hive-link

# Stop or delete the service
pm2 stop hive-link
pm2 delete hive-link

# Tail logs
pm2 logs hive-link