CLI Reference
Complete reference for the Railguard command-line interface.
Railguard is invoked via the rg command. It supports multiple subcommands for different operation modes.
Synopsis
Commands
rg run
Run a child command through the Railguard proxy. The proxy starts, runs your command, and shuts down when the command exits.
Arguments:
<COMMAND>...— The command to run (everything after--)
Examples:
Environment Injection:
Railguard automatically sets these environment variables for your child process:
RPC_URL=http://127.0.0.1:<port>ETH_RPC_URL=http://127.0.0.1:<port>
rg proxy
Start the proxy server without running a child command. Useful for:
- Background operation
- Multiple scripts using the same proxy
- Integration with external process managers
Examples:
Shutdown:
- Press
Ctrl+Cfor graceful shutdown - Or send
SIGTERM
rg login
Authenticate with Railguard Cloud for remote policy sync and log retention.
This initiates a device code flow:
- Opens your browser (or prints a URL)
- You authorize on the Railguard website
- CLI receives an access token
- Token is stored locally for future requests
Global Options
--config, -c
Specify the path to your configuration file.
Default: railguard.toml in the current directory.
--port, -p
Override the server port from the config file.
This is useful for running multiple Railguard instances simultaneously.
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Child process failed (for rg run) |
| 1 | Configuration error |
| 1 | Server bind failure |
When using rg run, the exit code matches the child process exit code.
Signals
| Signal | Behavior |
|---|---|
SIGINT (Ctrl+C) | Graceful shutdown within 5 seconds |
SIGTERM | Graceful shutdown within 5 seconds |
SIGKILL | Immediate termination (no cleanup) |
Environment Variables
Railguard reads these environment variables:
| Variable | Purpose |
|---|---|
RUST_LOG | Log level (e.g., debug, info, warn) |
RAILGUARD_CONFIG | Alternative to -c flag |
Variables in your config are expanded using ${VAR_NAME} syntax:
Usage Patterns
CI/CD Integration
Multiple Instances
Docker
systemd Service
Next Steps
- Configuration — Config file reference
- TUI — Terminal interface guide
- Policy Engine — How inspection works