You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Init System of [Cudane], a Good Replace of [Systemd] Written in [Rust] That Completely [Silent], So You Won't Be Scared Again of Terrifying Streaming Output, Cesar runs as the first process during boot, manages all system services through an [Async] dependency graph, and provides a [CLI] for administration after boot completes.
/etc/cesar/services/*.ini (user, higher priority — overrides system configs with the same Name)
CLI
CLI
Flags
csr [OPTIONS] [COMMAND]
Options:
-h, --help Print help
-V, --version Print version
Conventions
All subcommands support - and -- flags interchangeably
Mixed flagging is supported: csr service -n greetd -f is the same as csr service --name greetd --force
Every command group has a short alias: csr svc = csr service, csr sys = csr system, etc.
Every subcommand has short aliases where applicable
All output commands support --json for machine-readable output
Boolean flags default to false when omitted
Timeout flags default to 30 seconds (services) or 60 seconds (system operations) when omitted
service
Service management and lifecycle control. Alias: svc
csr service <COMMAND>
Commands:
start Start a service (alias: up)
stop Stop a service (alias: dn)
restart Restart a service (alias: rs)
reload Reload Services (alias: rl)
kill Send signal to a service
enable Enable a service for boot
disable Disable a service
status Show service status
list List all services (alias: ls)
inspect Inspect service details
log View service logs
cat Show service config file
edit Edit service config
diff Diff running vs on-disk config
validate Validate Services
create Create a new service config
rm Remove a service
monitor Monitor service health
watch Watch service events in real-time
tree Show dependency tree (alias: dep)
service start
Start a service. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
wait
-w
--wait
bool
false
Wait for service to reach target state
timeout
-t
--timeout
u64
30
Timeout in seconds
csr service start udevd
csr service start -n greetd
csr service start --name greetd --wait
csr service start -n greetd -w -t 60
csr svc up -n udevd
service stop
Stop a service. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
force
-f
--force
bool
false
Force operation even if transitional state
timeout
-t
--timeout
u64
30
Timeout in seconds
csr service stop greetd
csr service stop -n greetd --force
csr service stop -n greetd -f -t 10
csr svc dn -n greetd -f
service restart
Restart a service. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
force
-f
--force
bool
false
Force operation
timeout
-t
--timeout
u64
30
Timeout in seconds
csr service restart greetd
csr service restart -n greetd -f -t 10
csr svc rs -n greetd
service reload
Reload Services. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
signal
-s
--signal
Option<String>
SIGHUP
Signal to send
csr service reload pipewire
csr service reload -n pipewire -s SIGHUP
csr svc rl -n pipewire
service kill
Send signal to a service. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
signal
-s
--signal
Option<String>
SIGTERM
Signal to send
csr service kill -n snapd -s KILL
csr service kill --name snapd --signal SIGTERM
service enable
Enable a service for boot. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
boot
-b
--boot
bool
false
Enable for boot only
now
-W
--now
bool
false
Enable and start immediately
csr service enable greetd
csr service enable -n greetd --now
csr service enable -n greetd -b
service disable
Disable a service. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
now
-W
--now
bool
false
Disable and stop immediately
csr service disable acpid
csr service disable -n acpid --now
service status
Show service status. Name is optional (shows all if omitted).
Flag
Short
Long
Type
Default
Description
name
-n
--name
Option<String>
—
Service name (omit for all)
json
-j
--json
bool
false
Output as JSON
quiet
-q
--quiet
bool
false
Quiet output
csr service status
csr service status -n greetd
csr service status --json
csr service status -n greetd -j -q
service list
List all services.
Flag
Short
Long
Type
Default
Description
all
-a
--all
bool
false
Show all including stopped
failed
-f
--failed
bool
false
Show only failed
running
-r
--running
bool
false
Show only running
sort
-s
--sort
Option<String>
—
Sort by field
json
-j
--json
bool
false
Output as JSON
minimal
-m
--minimal
bool
false
Minimal output
csr service list
csr service list -a
csr service list -r
csr service list -f
csr service list -s name -j
csr service list --all --json --sort name
csr svc ls -a -j
service inspect
Inspect service details. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
raw
-r
--raw
bool
false
Show raw config
deps
-d
--deps
bool
false
Show dependencies
pid
-p
--pid
bool
false
Show PID info
json
-j
--json
bool
false
Output as JSON
csr service inspect -n greetd
csr service inspect -n greetd -d -p
csr service inspect --name greetd --deps --pid --json
service log
View service logs.
Flag
Short
Long
Type
Default
Description
name
-n
--name
Option<String>
—
Service name
follow
-f
--follow
bool
false
Follow log in real-time
lines
-l
--lines
usize
50
Number of lines
level
-L
--level
Option<String>
—
Filter by level
grep
-g
--grep
Option<String>
—
Grep pattern
since
-S
--since
Option<String>
—
Show since timestamp
csr service log -n greetd
csr service log -n greetd -f
csr service log -n greetd -l 100 -L CRITICAL
csr service log -n greetd -g "not found"
csr service log --name greetd --follow --lines 200
service cat
Show service config file. Requires --name.
csr service cat -n greetd
csr service cat --name udevd
service edit
Edit service config. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
editor
-e
--editor
Option<String>
—
Editor to use
csr service edit -n greetd
csr service edit -n greetd -e vim
service diff
Diff running vs on-disk config. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
running
-r
--running
bool
false
Compare with running state
csr service diff -n greetd
csr service diff --name greetd --running
service validate
Validate Services.
Flag
Short
Long
Type
Default
Description
name
-n
--name
Option<String>
—
Service name (omit for all)
all
-a
--all
bool
false
Validate all services
strict
-s
--strict
bool
false
Strict validation
csr service validate -a
csr service validate -n greetd -s
csr service validate --all --strict
service create
Create a new service config. Requires --name and --exec.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
exec
-e
--exec
String
—
Exec path (required)
requires
-r
--requires
Option<String>
—
Required services (comma-separated)
restart
-R
--restart
Option<String>
—
Restart policy
socket
-s
--socket
Option<String>
—
Sockets spec
description
-d
--description
Option<String>
—
Description
environment
-E
--environment
Option<String>
—
Environment variables (space-separated KEY=VALUE)
working-directory
-w
--working-directory
Option<String>
—
Working directory
csr service create -n my-svc -e /usr/bin/my-svc
csr service create --name my-svc --exec /usr/bin/my-svc --requires udevd --restart always
csr service create -n my-svc -e /usr/bin/my-svc -r udevd,seatd -R always -s unix:/run/my-svc.sock -d "My service"
csr service create -n my-svc -e /usr/bin/my-svc -E "HOME=/var/lib/my-svc level=debug" -w /var/lib/my-svc
service rm
Remove a service. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
force
-f
--force
bool
false
Force removal
purge
-p
--purge
bool
false
Remove config files too
csr service rm -n my-svc
csr service rm --name my-svc --force --purge
service monitor
Monitor service health. Requires --name.
Flag
Short
Long
Type
Default
Description
name
-n
--name
String
—
Service name (required)
interval
-i
--interval
u64
1000
Poll interval in ms
threshold
-t
--threshold
u32
3
Failure threshold before alert
csr service monitor -n greetd
csr service monitor -n greetd -i 500 -t 5
csr service monitor --name greetd --interval 2000 --threshold 10
service watch
Watch service events in real-time.
Flag
Short
Long
Type
Default
Description
name
-n
--name
Option<String>
—
Service name
events
-e
--events
Option<String>
—
Event types to watch
csr service watch
csr service watch -n greetd
csr service watch -e start,stop,fail
service tree
Show dependency tree.
Flag
Short
Long
Type
Default
Description
all
-a
--all
bool
false
Show all services
flat
-f
--flat
bool
false
Flat list output
graph
-g
--graph
bool
false
ASCII graph output
csr service tree
csr service tree -a
csr service tree -g
csr service tree --all --graph
csr svc dep -a -g
system
System-wide operations and control. Alias: sys
csr system <COMMAND>
Commands:
boot Boot the system with splash
shutdown Graceful shutdown
reboot Reboot the system
poweroff Power off the system
emergency Emergency mode
suspend Suspend to RAM
resume Resume from suspend
freeze Freeze all processes (cgroup freezer)
thaw Thaw frozen processes
mount Mount filesystem
umount Unmount filesystem
sync Sync filesystems
hostname Get/set hostname
uptime Show system uptime
kernel Kernel information
env Environment variable management
resource Resource monitoring
cgroup Cgroup management
device Device management
system boot
Flag
Short
Long
Type
Default
Description
splash
-s
--splash
bool
false
Show splash screen
verbose
-v
--verbose
bool
false
Verbose output
single
-S
--single
bool
false
Single-user mode
emergency
-e
--emergency
bool
false
Emergency boot
csr system boot
csr system boot -s -v
csr system boot --single
csr system boot --emergency
system shutdown
Flag
Short
Long
Type
Default
Description
force
-f
--force
bool
false
Force shutdown
timeout
-t
--timeout
u64
60
Timeout in seconds
reboot
-r
--reboot
bool
false
Reboot after shutdown
csr system shutdown
csr system shutdown -f
csr system shutdown -t 30
csr system shutdown --force --timeout 120
system reboot
Flag
Short
Long
Type
Default
Description
force
-f
--force
bool
false
Force reboot
timeout
-t
--timeout
u64
60
Timeout in seconds
mode
-m
--mode
Option<String>
—
Reboot mode (warm/cold)
csr system reboot
csr system reboot -f -t 30
csr system reboot --mode cold
system poweroff
Flag
Short
Long
Type
Default
Description
force
-f
--force
bool
false
Force poweroff
timeout
-t
--timeout
u64
60
Timeout in seconds
csr system poweroff
csr system poweroff -f -t 10
system emergency
Flag
Short
Long
Type
Default
Description
reason
-r
--reason
Option<String>
—
Reason for emergency
csr system emergency
csr system emergency -r "disk failure"
system suspend
Flag
Short
Long
Type
Default
Description
hibernate
-H
--hibernate
bool
false
Hibernate instead of suspend
hybrid
-y
--hybrid
bool
false
Hybrid suspend
csr system suspend
csr system suspend -H
csr system suspend --hybrid
system resume
No flags.
csr system resume
system freeze
Flag
Short
Long
Type
Default
Description
timeout
-t
--timeout
Option<u64>
—
Timeout in seconds
csr system freeze
csr system freeze -t 60
system thaw
No flags.
csr system thaw
system mount
Flag
Short
Long
Type
Default
Description
source
-s
--source
Option<String>
—
Source device/path
target
-t
--target
Option<String>
—
Target mount point
type
-T
--type
Option<String>
—
Filesystem type
options
-o
--options
Option<String>
—
Mount options
recursive
-r
--recursive
bool
false
Recursive mount
remount
-R
--remount
bool
false
Remount
csr system mount -s /dev/sda1 -t /mnt/data -T ext4
csr system mount --source /dev/sda1 --target /mnt/data --type ext4 --options rw,noatime
csr system mount -s /dev/sda1 -t /mnt/data -r
csr system mount -s /dev/sda1 -t /mnt/data -R
system umount
Flag
Short
Long
Type
Default
Description
target
-t
--target
Option<String>
—
Target mount point
recursive
-r
--recursive
bool
false
Recursive unmount
lazy
-l
--lazy
bool
false
Lazy unmount
force
-f
--force
bool
false
Force unmount
detach
-d
--detach
bool
false
Detach loopback
csr system umount -t /mnt/data
csr system umount -t /mnt/data -r
csr system umount -t /mnt/data -l -f
system sync
Flag
Short
Long
Type
Default
Description
file-systems
-f
--file-systems
Option<String>
—
Sync specific filesystems
data
-d
--data
bool
false
Sync data only (no metadata)
csr system sync
csr system sync -f /home,/var
csr system sync --data
system hostname
Flag
Short
Long
Type
Default
Description
set
-s
--set
Option<String>
—
Set hostname
short
-S
--short
bool
false
Show short hostname
long
-l
--long
bool
false
Show long hostname
static
-t
--static
bool
false
Show static hostname
json
-j
--json
bool
false
Output as JSON
csr system hostname
csr system hostname -s my-cudane
csr system hostname -S
csr system hostname -l
csr system hostname -j
csr system hostname --set my-cudane --json
system uptime
Flag
Short
Long
Type
Default
Description
since
-s
--since
bool
false
Show since boot time
seconds
-S
--seconds
bool
false
Show in seconds
json
-j
--json
bool
false
Output as JSON
csr system uptime
csr system uptime -s
csr system uptime -S
csr system uptime -j
system kernel
Subcommands: list (alias: ls), log, parameters (alias: parm), module
csr system kernel <SUBCOMMAND>
Subcommands:
list List kernel modules (alias: ls)
log Show kernel log (dmesg)
parameters Show kernel parameters (alias: parm)
module Module operations
csr system kernel list
csr system kernel ls
csr system kernel log -f -l 100
csr system kernel log --follow --lines 200 -L warning
csr system kernel parameters
csr system kernel parm -g vm
csr system kernel module -n usb-storage -l
csr system kernel module -n usb-storage -u
system env
Flag
Short
Long
Type
Default
Description
set
-s
--set
Option<String>
—
Set environment variable
get
-g
--get
Option<String>
—
Get environment variable
unset
-u
--unset
Option<String>
—
Unset environment variable
list
-l
--list
bool
false
List all
json
-j
--json
bool
false
Output as JSON
csr system env -l
csr system env -g PATH
csr system env -s MY_VAR=hello
csr system env -u MY_VAR
csr system env --list --json
system resource
Flag
Short
Long
Type
Default
Description
type
-t
--type
Option<String>
—
Resource type (cpu/memory/io/network)
interval
-i
--interval
Option<u64>
—
Snapshot interval
format
-f
--format
Option<String>
—
Output format
json
-j
--json
bool
false
Output as JSON
csr system resource
csr system resource -t memory
csr system resource -t cpu -i 5
csr system resource -j
system cgroup
Flag
Short
Long
Type
Default
Description
list
-l
--list
bool
false
List cgroups
create
-c
--create
Option<String>
—
Create cgroup
destroy
-d
--destroy
Option<String>
—
Destroy cgroup
attach
-a
--attach
Option<String>
—
Attach PID to cgroup
stats
-s
--stats
Option<String>
—
Show cgroup stats
pids
-p
--pids
Option<String>
—
PIDs to attach
csr system cgroup -l
csr system cgroup -c my-cgroup
csr system cgroup -a my-cgroup -p 1234
csr system cgroup -s my-cgroup
csr system cgroup -d my-cgroup
system device
Flag
Short
Long
Type
Default
Description
list
-l
--list
bool
false
List devices
attach
-a
--attach
Option<String>
—
Attach device
detach
-d
--detach
Option<String>
—
Detach device
info
-i
--info
Option<String>
—
Device info
csr system device -l
csr system device -i sda
csr system device -a /dev/sdb
csr system device -d /dev/sdb
config
Configuration management. Alias: cfg
csr config <COMMAND>
Commands:
show Show configuration
get Get a config value
set Set a config value
edit Edit configuration file
diff Diff configurations
validate Validate configuration
import Import configuration
export Export configuration
backup Backup configuration
restore Restore configuration
schema Generate schema
migrate Migrate configuration
config show
Flag
Short
Long
Type
Default
Description
format
-f
--format
Option<String>
—
Output format
file
-F
--file
Option<String>
—
Config file path
section
-s
--section
Option<String>
—
Section filter
csr config show
csr config show -s boot
csr config show -F /etc/cesar/services/udevd.ini
csr config show --format json
config get
Flag
Short
Long
Type
Default
Description
key
-k
--key
String
—
Key to get (required)
default
-d
--default
Option<String>
—
Default value
csr config get -k boot.timeout
csr config get --key boot.timeout --default 30
config set
Flag
Short
Long
Type
Default
Description
key
-k
--key
String
—
Key to set (required)
value
-v
--value
String
—
Value to set (required)
file
-F
--file
Option<String>
—
Config file
csr config set -k boot.timeout -v 60
csr config set --key boot.verbose --value true -F /etc/cesar/config.ini
csr log <COMMAND>
Commands:
view View log entries
tail Show last N lines
head Show first N lines
grep Search log entries
clear Clear log entries
rotate Rotate log files
archive Archive log entries
export Export log entries
follow Follow log in real-time
errors Show only errors
warnings Show only warnings
stats Log statistics
summary Log summary
csr socket <COMMAND>
Commands:
list List sockets (alias: ls)
status Show socket status
create Create a socket
destroy Destroy a socket
monitor Monitor socket activity
trace Trace socket events
activate Activate a socket
query Query socket
socket list
Flag
Short
Long
Type
Default
Description
type
-t
--type
Option<String>
—
Socket type filter
state
-s
--state
Option<String>
—
State filter
service
-S
--service
Option<String>
—
Service filter
json
-j
--json
bool
false
Output as JSON
csr socket list
csr socket ls -t unix
csr socket list -s listening -S greetd -j
socket status
Flag
Short
Long
Type
Default
Description
path
-p
--path
Option<String>
—
Socket path
verbose
-v
--verbose
bool
false
Verbose output
csr socket status -p /run/cesar.sock
csr socket status -p /run/cesar.sock -v
csr daemon <COMMAND>
Commands:
start Start a daemon
stop Stop a daemon
restart Restart a daemon
status Daemon status
list List daemons (alias: ls)
log Daemon logs
install Install a daemon
uninstall Uninstall a daemon
update Update a daemon
rollback Rollback a daemon
pin Pin daemon version
trust Trust management
System snapshots and state management. Alias: snap
csr snapshot <COMMAND>
Commands:
create Create a snapshot
list List snapshots (alias: ls)
restore Restore a snapshot
delete Delete a snapshot
diff Diff two snapshots
export Export a snapshot
import Import a snapshot
csr query <COMMAND>
Commands:
service Query service information
boot Query boot information
system Query system information
dependency Query dependencies
history Query history
resource Query resource usage
health Health check
query service
Flag
Short
Long
Type
Default
Description
name
-n
--name
Option<String>
—
Service name
format
-f
--format
Option<String>
—
Output format
fields
-F
--fields
Option<String>
—
Fields to show
json
-j
--json
bool
false
Output as JSON
csr query service
csr query service -n greetd
csr query service -n greetd -F name,pid,state -j
csr debug <COMMAND>
Commands:
trace Trace a process
strace Strace-like tracing
dump Dump system state
core Core dump analysis
profile Profile a process
stress Stress test
test Run self-tests
csr debug test -a
csr debug test -m config -v
csr debug test --all --verbose
self
Cesar self-management. Alias: me
csr self <COMMAND>
Commands:
status Cesar status
update Self-update
version Version information
completions Generate completions
config Cesar configuration
self status
Shows PID, role, uptime, and runs built-in health checks (kernel, filesystems, disk, service configs, zombies, TCP listeners).
Flag
Short
Long
Type
Default
Description
verbose
-v
--verbose
bool
false
Verbose output
csr self status
csr self status -v
Health checks run automatically:
On boot: silently, issues logged to /var/log/cesar.md
On self status: displayed inline with [CTX] and [FIX] for each issue
1. Mount virtual filesystems (/proc, /sys, /dev)
2. Setup signal handlers:
- SIGCHLD -> sets atomic flag (deferred zombie reaping in main loop)
- SIGTERM -> sets atomic flag (deferred graceful shutdown in main loop)
- SIGINT -> same as SIGTERM
- SIGHUP -> sets atomic flag (deferred config reload in main loop)
- SIGPIPE -> ignored (prevents broken pipe crashes)
3. Show Plymouth splash
4. Load all .ini configs from /system/lib/cesar/services/ and /etc/cesar/services/
(user configs in /etc/cesar/services/ override system configs with the same Name)
5. Build dependency graph (DAG) — detect cycles
6. Activate sockets for services with Socket= configs
7. Compute boot order (topological sort -> levels)
8. For each level (in parallel):
a. Check dependency satisfaction (skip if deps not met)
b. Mark service as Starting
c. Fork/exec the service binary (with Environment= and WorkingDirectory= if set)
d. Mark as Running (or Failed)
e. Log every state transition
9. Log boot complete
10. On failure: print error tree to stderr with [CTX] and [FIX]
11. Drop to main loop:
- Poll for zombie children (SIGCHLD deferred via atomic flag)
- On crash: auto-restart if Restart=always (with 5-attempt limit per boot)
- On SIGTERM: graceful shutdown (SIGTERM -> 5s grace -> SIGKILL process groups)
CLI boot (csr with no arguments) runs the same sequence but outputs to stdout instead of Plymouth.
Resolution
Resolution
The DAG engine performs topological sorting with cycle detection:
Config ownership — validates service config file ownership
Process groups — each service gets its own process group (via setpgid)
Capability tracking — reads /proc/PID/status for CapBnd
Seccomp awareness — reads /proc/self/status for Seccomp filters
Network listener detection — parses /proc/net/tcp for open ports
Audit reporting — csr security audit checks all of the above
Process isolation:
spawn_service_env():
fork()
setsid() -> new session (detach from parent TTY)
setpgid(0, 0) -> own process group
umask(022)
redirect stdin/stdout/stderr -> /dev/null
if WorkingDirectory= set:
chdir(working_directory)
if Environment= set:
putenv(K=V) for each pair (CStrings kept alive for pointer safety)
execvp(binary, [binary, arg1, arg2, ...]) (args split from command string)
Shutdown kills entire process group:
kill_service_group(pid, signal):
pgid = getpgid(pid)
kill(-pgid, signal) -> kills all children
Filesystem
Filesystem
/sbin/init -> hardlink to /system/bin/csr
/system/bin/csr -> main binary
/system/bin/csl -> log viewer
/system/lib/cesar/services/ -> system service configs (.ini)
/etc/cesar/services/ -> user service configs (.ini)
/etc/cesar/enabled/ -> enabled service symlinks
/var/log/cesar.md -> markdown log file
/var/lib/cesar/snapshots/ -> snapshot storage
[profile.release]
opt-level = "s"# Optimize for sizelto = true# Link-time optimizationcodegen-units = 1# Single codegen unit for maximum optimizationpanic = "abort"# No unwindingstrip = true# Strip debug symbols
All build systems auto-detect x86_64/aarch64 and select the correct musl target. Cross-compilation files are in env.mk, toolchain.cmake, and cross.txt (generated via gen-cross.sh).
/system/lib/cesar/services/ # System service configs (read-only)
/etc/cesar/services/ # User service configs (writable)
/etc/cesar/enabled/ # Enabled service symlinks
/var/log/cesar.md # Markdown log file
/var/lib/cesar/snapshots/ # Snapshot storage
Testing
# Run all tests (unit + integration)
cargo test# Run with stdout/stderr visible
cargo test -- --nocapture
# Run a specific test by name
cargo test -- test_name
# Run with all features and release mode
cargo test --release --all-features
Self-test coverage:
Test
What it checks
Config parsing
.ini files parse without errors
DAG engine
Topological sort produces correct order, cycle detection works
Service directory
/system/lib/cesar/services/ and /etc/cesar/services/ exist
Logger
Write + read roundtrip to /var/log/cesar.md
Linting
# Clippy (lint checks)
cargo clippy -- -D warnings
# Format check
cargo fmt --check
# Format in place
cargo fmt
Auditing
# Check for security advisories in dependencies
cargo audit
Debugging
# Build with debug assertions enabled in release
cargo build --profile release-debug # requires Cargo.toml profile# Run with RUST_LOG for tracing
RUST_LOG=debug csr
# Run with backtrace on panic
RUST_BACKTRACE=1 csr
# Run under strace for syscall tracing
strace -f -o /tmp/csr.strace ./target/release/csr
# Memory profiling with valgrind
valgrind --tool=massif ./target/release/csr
ms_print massif.out.*| less
Profiling
# perf profiling (Linux)
perf record --call-graph dwarf ./target/release/csr
perf report
# Generate flamegraph
perf script | inferno-collapse-perf > stacks.folded
inferno-flamegraph stacks.folded > flamegraph.svg
# CPU sampling with perf stat
perf stat -e cycles,instructions,cache-misses,faults ./target/release/csr
The Python subsystem is a dual-mode plugin, theme, and TUI engine.
In-process (embedded) — the PythonEngine embeds a Python interpreter via PyO3 to load themes, TUIs, and hook plugins and render prompts in-process when the [python] section is enabled.
Out-of-process (CLI) — csr plugin run, csr theme apply, and csr tui apply spawn python3/sh as separate processes; Cesar never runs untrusted plugin code inside the init process for these commands.
UNIX domain socket events — fire-and-forget JSON messages at /run/cesar/event.sock
Architecture
┌──────────────────────────────────────────────────────────┐
│ ┌───────────────┐ ┌───────────────┐ ┌──────────────┐ │
│ │ PluginManager │ │ EventBus │ │ CLI dispatch │ │
│ │ (p.desc) │ │ (event.sock) │ │ plugin/ │ │
│ │ (t.desc) │ └──────┬────────┘ │ theme/tui │ │
│ └──────┬────────┘ │ └─────┬────────┘ │
└─────────┼──────────────────┼──────────────────┼──────────┘
│ spawn + timeout │ emit JSON │
▼ ▼ ▼
┌─────────────────────────────────────────────────────┐
│ Python Process(es) │
│ Single-file plugins, themes, and TUIs │
│ Each can have its own embedded venv │
│ No restrictions — any library, any tool │
└─────────────────────────────────────────────────────┘
Each plugin gets a numbered section [plugin.N]. The name and path fields are required. The aliases table maps any alias string to any command string — no limits on characters, flags, or structure. The only restriction is that each alias must be unique across all plugins.
The descriptor is located at the first existing, parseable file among (in order): ~/.config/cesar/p.desc, /etc/cesar/p.desc, ./p.desc, or <cwd>/p.desc. path values support ~ expansion. Plugins defined here appear automatically in csr plugin list, info, run, and remove without a separate install step.
/etc/cesar/t.desc — Theme and TUI descriptors
[theme.1]
name = "catppuccin"path = "/etc/cesar/themes/catppuccin.py"
[theme.2]
name = "nord"path = "/etc/cesar/themes/nord.py"
[tui.1]
name = "htop-like"path = "/etc/cesar/tuis/htop.py"
[tui.2]
name = "dashboard"path = "/etc/cesar/tuis/dashboard.py"
Themes and TUIs share the same t.desc file but are in separate sections. [theme.N] for themes and [tui.N] for TUIs. Both require name and path; an optional description string is shown as a Desc: line in csr theme list/info and csr tui list/info. The descriptor is loaded from the first existing, parseable file among (in order): ~/.config/cesar/t.desc, /etc/cesar/t.desc, ./t.desc, or <cwd>/t.desc. path values support ~ expansion.
CLI Commands
Plugin commands
Command
Description
csr plugin list
List all installed plugins with their aliases
csr plugin info <name>
Show plugin details and file size
csr plugin run <alias> [args...]
Execute a plugin by alias with optional extra args
Install a plugin file into /etc/cesar/plugins and register it (-f forces overwrite)
csr plugin remove <name>
Uninstall a plugin
Theme commands
Command
Description
csr theme list
List all installed themes
csr theme info <name>
Show theme details
csr theme apply <name>
Execute a theme (runs its Python file)
csr theme install <path> [-n <name>] [-f]
Install a theme file into /etc/cesar/themes and register it (-f forces overwrite)
csr theme remove <name>
Uninstall a theme
TUI commands
Command
Description
csr tui list
List all installed TUIs
csr tui info <name>
Show TUI details
csr tui apply <name>
Launch a TUI (runs its Python file)
csr tui install <path> [-n <name>] [-f]
Install a TUI file into /etc/cesar/tuis and register it (-f forces overwrite)
csr tui remove <name>
Uninstall a TUI
Plugin Execution Model
Alias lookup — csr plugin run <alias> resolves the alias string against the plugin registry (populated from p.desc or csr plugin install).
Substitution — If the alias command contains {}, the extra CLI args replace it; otherwise extra args are appended.
Spawn — The resulting command string is executed via sh -c with the working directory set to the plugin's parent directory.
Output — stdout is returned on success, stderr on failure.
Execution is synchronous at the command level. Plugins run as independent processes and cannot crash the init system.
Event Bus
Cesar emits JSON events to /run/cesar/event.sock (UNIX datagram) during boot and service lifecycle. Plugins can listen on this socket to react to system events:
Each plugin/theme/TUI is a single Python file that can manage its own virtual environment. When the embedded [python] engine is enabled, an explicit venv_path in the config activates that virtualenv's site-packages before any theme, TUI, or plugin is loaded. Out-of-process commands (csr plugin run, csr theme apply, csr tui apply) execute the command/script as written; a plugin that needs dependencies can create and use its own venv from inside its script.
No Restrictions
No specific structure — A plugin can be 10 lines or 10,000 lines
No naming conventions — Names can contain any characters
No alias limits — Any alias string, any flag combination, any command string
No library restrictions — Import anything from the Python ecosystem
No file size limits — A single file can contain an entire application
No hooks required — The file is just a Python script; what it does is entirely up to the author
Example Plugin
#!/usr/bin/env python3"""telegram-notifier: Send alerts to Telegram when services fail."""importjson, os, sys, requestsVENV_DIR=os.path.join(os.path.dirname(__file__), f"{os.path.basename(__file__)}.venv")
defensure_venv():
ifnotos.path.exists(VENV_DIR):
importsubprocesssubprocess.run([sys.executable, "-m", "venv", VENV_DIR], check=True)
pip=os.path.join(VENV_DIR, "bin", "pip")
subprocess.run([pip, "install", "requests"], check=True)
defmain():
ensure_venv()
# Use the venv's Python for the actual logicmsg=" ".join(sys.argv[1:]) or"Service alert from Cesar"token=os.environ.get("TELEGRAM_TOKEN", "")
chat_id=os.environ.get("TELEGRAM_CHAT", "")
iftokenandchat_id:
requests.post(f"https://api.telegram.org/bot{token}/sendMessage",
json={"chat_id": chat_id, "text": msg})
if__name__=="__main__":
main()
Configuration
Configuration
Cesar reads its main configuration from /etc/cesar/cesar.ini. All fields have defaults, so the file is optional.