server¶
The fujin server command provides server management operations.
Overview¶
Use fujin server to manage server-level operations:
View server information
Bootstrap server with required dependencies
Upgrade server components (Caddy, uv, Python, system packages)
Create deployment users
Set up SSH keys
Execute commands on the server with optional app environment
Subcommands¶
status¶
Display system information about the host.
Shows OS version, CPU, memory, and other system details using fastfetch when available.
Example:
$ fujin server status
bootstrap¶
Install system dependencies required for fujin deployments.
This command:
Creates
/opt/fujindirectory structure with proper permissionsCreates
/opt/fujin/.pythonshared Python installation directoryInstalls uv (Python package manager)
Installs Caddy web server (if webserver enabled)
Sets up necessary system packages
Configures Caddy to auto-load configurations from
/etc/caddy/conf.d/
The bootstrap process creates a shared Python directory at /opt/fujin/.python where UV installs Python interpreters. This allows:
Multiple applications to share Python installations
Stronger systemd security with
ProtectHome=true(home directories completely inaccessible)Better isolation between deployment users and runtime users
Example:
$ fujin server bootstrap
Note
This is automatically run as part of fujin up, so you typically don’t need to run it manually.
upgrade¶
Upgrade server components to their latest versions.
This command upgrades:
System packages - Updates all installed packages via apt (non-critical, won’t stop other upgrades if it fails)
Caddy web server - Upgrades to the latest version using
caddy upgradeuv package manager - Updates uv to the latest version using
uv self updatePython installations - Upgrades all Python versions managed by uv using
uv python upgrade
The upgrade command shows version changes (e.g., “Caddy upgraded from v2.7.0 to v2.8.0”) and gracefully skips components that aren’t installed.
Example:
$ fujin server upgrade
Output example:
Upgrading server components...
Upgrading system packages...
✓ System packages upgraded successfully!
Upgrading Caddy web server...
✓ Caddy upgraded from v2.7.0 to v2.8.0!
Upgrading uv package manager...
✓ uv is already at the latest version (uv 0.5.0)
Upgrading Python installations...
✓ Python installations upgraded successfully!
✓ All server components upgraded successfully!
Note
System package upgrades (apt) are non-critical - if they fail, the command will continue upgrading other components. This ensures Caddy, uv, and Python upgrades can still proceed even if system packages have issues.
create-user¶
Create a new user with sudo access and SSH key setup.
Creates a deployment user with:
Passwordless sudo access
SSH keys copied from root user
Home directory and proper permissions
Example:
$ fujin server create-user deploy
This creates a user named “deploy” that you can use for deployments.
setup-ssh¶
Interactive wizard to set up SSH keys and update fujin.toml.
This interactive command:
Generates SSH keys if needed
Copies keys to the server
Updates fujin.toml with key path
Configures SSH connection settings
Example:
$ fujin server setup-ssh
Common Workflows¶
Initial server setup
# 1. Set up SSH keys (if not already configured)
fujin server setup-ssh
# 2. Create a deployment user
fujin server create-user deploy
# 3. Update fujin.toml to use the new user
# Edit fujin.toml: user = "deploy"
# 4. Bootstrap the server
fujin server bootstrap
Or use the all-in-one command:
fujin up # Does bootstrap + deploy in one step
Keep server up to date
# Upgrade all server components
fujin server upgrade
# Target specific host
fujin server upgrade -H production
Check server status
fujin server status
exec¶
Execute commands on the server, with optional app environment.
Usage:
fujin server exec [--appenv] COMMAND [ARGS...]
Options:
--appenvChange to app directory and load environment from
.appenvfile. Runs as app user.-H, --host HOSTTarget a specific host in multi-host setups.
Plain Server Command (default):
Run any command on the server as the deploy user:
# Check disk space
fujin server exec df -h
# View processes
fujin server exec ps aux
# Any server command
fujin server exec ls -la /var/log
With App Environment (–appenv):
Run commands in your app directory with environment variables loaded as the app user:
# Run Python script with app environment
fujin server exec --appenv python script.py
# Access database with credentials from .env
fujin server exec --appenv psql -U \$DB_USER -d \$DB_NAME
# Start interactive bash in app directory
fujin server exec --appenv bash
This is equivalent to:
cd /path/to/app && source .appenv && your-command
Important
User Context: Commands run with different permissions depending on the flag:
Without –appenv: Run as the deploy user
With –appenv: Run as the app user (can write to app-owned files)
Common patterns with aliases:
Create shortcuts in fujin.toml:
[aliases]
bash = "server exec --appenv bash"
logs = "server exec tail -f /var/log/syslog"
Examples:
# Database operations with environment
fujin server exec --appenv 'psql -U $DB_USER -d $DB_NAME'
# Export database
fujin server exec --appenv 'pg_dump $DB_NAME' > backup.sql
# Check disk space on production
fujin server exec df -h -H production
# Run maintenance script
fujin server exec --appenv python healthcheck.py
See Also¶
app - Application management and
app execcommandup - One-command server setup and deployment
deploy - Deployment workflow and permission model
How to… - Setup guides
Configuration - Host configuration reference