This document provides a comprehensive reference for all Zinit command line options and commands.
Zinit uses a command-based CLI with the following general structure:
zinit [FLAGS] [OPTIONS] [SUBCOMMAND]
These flags and options apply to all Zinit commands:
Flag/Option | Description |
---|---|
-d, --debug |
Run in debug mode with increased verbosity |
-h, --help |
Display help information |
-V, --version |
Display version information |
-s, --socket <PATH> |
Path to Unix socket (default: /var/run/zinit.sock ) |
Run Zinit in init mode, starting and maintaining configured services.
zinit init [FLAGS] [OPTIONS]
Flags:
--container
: Run in container mode, exiting on signal instead of rebooting
Options:
-c, --config <DIR>
: Service configurations directory (default:/etc/zinit/
)-b, --buffer <SIZE>
: Buffer size (in lines) to keep service logs (default:2000
)
Example:
# Run in init mode with custom config directory
zinit init -c /opt/services/
# Run in container mode
zinit init --container
Display a quick view of all currently known services and their status.
zinit list
Output: A JSON object with service names as keys and their status as values.
Example:
# List all services
zinit list
Show detailed status information for a specific service.
zinit status <SERVICE>
Arguments:
<SERVICE>
: Name of the service to show status for
Example:
# Check status of redis service
zinit status redis
Start a service. Has no effect if the service is already running.
zinit start <SERVICE>
Arguments:
<SERVICE>
: Name of the service to start
Example:
# Start the nginx service
zinit start nginx
Stop a service. Sets the target state to "down" and sends the stop signal.
zinit stop <SERVICE>
Arguments:
<SERVICE>
: Name of the service to stop
Example:
# Stop the redis service
zinit stop redis
Restart a service. If it fails to stop, it will be killed and then started again.
zinit restart <SERVICE>
Arguments:
<SERVICE>
: Name of the service to restart
Example:
# Restart the web service
zinit restart web
Start monitoring a service. The configuration is loaded from the server's config directory.
zinit monitor <SERVICE>
Arguments:
<SERVICE>
: Name of the service to monitor
Example:
# Monitor the database service
zinit monitor database
Remove a service from monitoring. You can only forget a stopped service.
zinit forget <SERVICE>
Arguments:
<SERVICE>
: Name of the service to forget
Example:
# Forget the backup service
zinit forget backup
Send a signal to a running service.
zinit kill <SERVICE> <SIGNAL>
Arguments:
<SERVICE>
: Name of the service to send signal to<SIGNAL>
: Signal name (e.g., SIGTERM, SIGKILL, SIGINT)
Example:
# Send SIGTERM to the redis service
zinit kill redis SIGTERM
# Send SIGKILL to force terminate a service
zinit kill stuck-service SIGKILL
Stop all services in dependency order and power off the system.
zinit shutdown
Example:
# Shutdown the system
zinit shutdown
Stop all services in dependency order and reboot the system.
zinit reboot
Example:
# Reboot the system
zinit reboot
View service logs from the Zinit ring buffer.
zinit log [FLAGS] [FILTER]
Flags:
-s, --snapshot
: If set, log prints current buffer without following
Arguments:
[FILTER]
: Optional service name to filter logs for
Examples:
# View logs for all services and follow new logs
zinit log
# View current logs for the nginx service without following
zinit log -s nginx
Zinit commands return the following exit codes:
Code | Description |
---|---|
0 | Success |
1 | Error (with error message printed to stderr) |
Zinit respects the following environment variables:
/etc/environment
: Read at startup to populate the environment for all services
# Start the zinit daemon in init mode
sudo zinit init
# List all services
zinit list
# Monitor a new service
zinit monitor myservice
# Check service status
zinit status myservice
# Stop a service
zinit stop myservice
# Remove a service from monitoring
zinit stop myservice
zinit forget myservice
# Start zinit in container mode
zinit init --container -c /app/services/
# Monitor a service
zinit monitor app
Since Zinit uses a simple line protocol, you can interact with it using netcat:
# List services
echo "list" | sudo nc -U /var/run/zinit.sock
# Start a service
echo "start redis" | sudo nc -U /var/run/zinit.sock