Server Commands

Overview

Server management commands provide functionality for registering, configuring, and managing remote cpm servers. These commands enable multi-server repository synchronization with health monitoring and status tracking.

Table of Contents


cpm servers list

Description

Display all registered cpm servers with their configuration details including host, port, SSH key, and main server designation.

Syntax

cpm servers list [flags]

Flags

Flag Type Description
--format <type> string Output format: table, json, yaml

Examples

cpm servers list

# Output:
# SERVERS
#
# Name     Host               Port  User  SSH Key      Main  Type
# -------  -----------------  ----  ----  -----------  ----  --------
# origin   git.example.com    22    git   main-server  Yes   server
# backup   backup.example.com 22    git   backup-key   No    server
# dev      192.168.1.100      2222  dev   dev-key      No    server
#
# Total: 3 servers (1 main server)

cpm servers add

Description

Register a new cpm server with connection details. Configures host, port, user, and SSH key for server operations.

Syntax

cpm servers add <name> <host> [flags]

Arguments

Argument Required Description
name Yes Unique server name
host Yes Server hostname or IP address

Flags

Flag Type Default Description
--port <number> int 22 SSH port number
--user <username> string git SSH username
--key <path> string - Path to SSH private key

Examples

# Basic server registration
cpm servers add origin 192.168.1.100

# Output:
# Server 'origin' registered successfully
# Host: 192.168.1.100
# Port: 22 (default)
# User: git (default)
# SSH Key: (none - will use default)

# Full configuration
cpm servers add prod prod.example.com --port 2222 --user deploy --key ~/.cpm/keys/prod

# Output:
# Server 'prod' registered successfully
# Host: prod.example.com
# Port: 2222
# User: deploy
# SSH Key: /home/user/.cpm/keys/prod

# Test connection
cpm servers status prod

Common Errors

Error Cause Solution
server name exists Name already registered Use different name or remove existing
invalid port Port out of range Use port 1-65535
key file not found SSH key path invalid Verify key exists

cpm servers remove

Description

Remove a registered server from configuration. Does not affect data on the remote server.

Syntax

cpm servers remove <name>

Arguments

Argument Required Description
name Yes Server name to remove

Examples

cpm servers remove old-server

# Prompt:
# Remove server 'old-server' (host: old.example.com)?
# This will not delete any data on the remote server. (y/N): y

# Output:
# Server 'old-server' removed from configuration

cpm servers set-main

Description

Designate a server as the main storage server. The main server is used as the default target for push/pull operations.

Syntax

cpm servers set-main <name>

Arguments

Argument Required Description
name Yes Server name to set as main

Examples

cpm servers set-main origin

# Output:
# Server 'origin' set as main server
# Default push/pull operations will use this server

cpm servers status

Description

Show health status and system information for servers including connectivity, disk usage, uptime, and load average.

Syntax

cpm servers status [name]

Arguments

Argument Required Description
name No Specific server name (if omitted, shows all)

Examples

# Status for all servers
cpm servers status

# Output:
# SERVER STATUS
#
# Name: origin (git.example.com)
# Status: Online
# Response time: 45ms
# Uptime: 127 days
# Disk usage: 234 GB / 500 GB (46%)
# Load average: 0.52, 0.48, 0.43
# Last checked: 2024-01-15 10:30:00
#
# Name: backup (backup.example.com)
# Status: Online
# Response time: 78ms
# Uptime: 89 days
# Disk usage: 456 GB / 1000 GB (45%)
# Load average: 0.23, 0.21, 0.19
# Last checked: 2024-01-15 10:30:00

# Status for specific server
cpm servers status origin

# Output:
# SERVER STATUS: origin
#
# Host: git.example.com
# Status: Online
# Response time: 42ms
# Uptime: 127 days, 14 hours
# Disk usage: 234 GB / 500 GB (46%)
# Free space: 266 GB
# Load average: 0.52, 0.48, 0.43
# Memory: 14.2 GB / 32 GB (44%)
# Repositories: 47
# Last sync: 2024-01-15 09:45:00
# Last checked: 2024-01-15 10:30:00

Server Management Workflows

Initial Setup

# Add main server
cpm servers add origin git.example.com --user git --key ~/.cpm/keys/main

# Set as main
cpm servers set-main origin

# Verify
cpm servers status origin

# Test with repository
cpm init test-repo
cpm push test-repo  # Uses main server

Multi-Server Configuration

# Add multiple servers
cpm servers add origin git.example.com
cpm servers add backup backup.example.com
cpm servers add dev dev.local --port 2222

# Set main server
cpm servers set-main origin

# Verify all servers
cpm servers status

# Use specific server
cpm push myrepo --to backup

Best Practices

Server Naming

  • Use descriptive names: origin, backup, prod, dev
  • Keep names short and memorable
  • Use consistent naming convention
  • Document server purposes

Configuration

  • Always configure SSH keys for servers
  • Test connectivity before using in production
  • Monitor server status regularly
  • Keep backup servers synchronized
  • Document server roles and responsibilities

See Also