Skip to main content

systemprompt_cli/commands/infrastructure/services/
mod.rs

1mod cleanup;
2mod dispatch;
3pub mod restart;
4pub mod serve;
5mod start;
6mod status;
7mod stop;
8mod types;
9
10use clap::Subcommand;
11
12pub use dispatch::{execute, load_service_configs};
13
14#[derive(Debug, Clone, Subcommand)]
15pub enum StartTarget {
16    Agent { agent: String },
17    Mcp { server_name: String },
18}
19
20#[derive(Debug, Clone, Subcommand)]
21pub enum StopTarget {
22    Agent {
23        agent: String,
24        #[arg(long, help = "Force stop (SIGKILL)")]
25        force: bool,
26    },
27    Mcp {
28        server_name: String,
29        #[arg(long, help = "Force stop (SIGKILL)")]
30        force: bool,
31    },
32}
33
34#[derive(Debug, Subcommand)]
35pub enum ServicesCommands {
36    #[command(
37        about = "Start API, agents, and MCP servers",
38        after_help = "EXAMPLES:\n  systemprompt infra services start\n  systemprompt infra \
39                      services start --api\n  systemprompt infra services start --agents --mcp\n  \
40                      systemprompt infra services start agent <name>"
41    )]
42    Start {
43        #[command(subcommand)]
44        target: Option<StartTarget>,
45
46        #[arg(long, help = "Start all services")]
47        all: bool,
48
49        #[arg(long, help = "Start API server only")]
50        api: bool,
51
52        #[arg(long, help = "Start agents only")]
53        agents: bool,
54
55        #[arg(long, help = "Start MCP servers only")]
56        mcp: bool,
57
58        #[arg(long, help = "Run in foreground (default)")]
59        foreground: bool,
60
61        #[arg(long, help = "Skip database migrations")]
62        skip_migrate: bool,
63
64        #[arg(long, help = "Kill process using the port if occupied")]
65        kill_port_process: bool,
66    },
67
68    #[command(
69        about = "Stop running services gracefully",
70        after_help = "EXAMPLES:\n  systemprompt infra services stop\n  systemprompt infra \
71                      services stop --api\n  systemprompt infra services stop agent <name> \
72                      [--force]"
73    )]
74    Stop {
75        #[command(subcommand)]
76        target: Option<StopTarget>,
77
78        #[arg(long, help = "Stop all services")]
79        all: bool,
80
81        #[arg(long, help = "Stop API server only")]
82        api: bool,
83
84        #[arg(long, help = "Stop agents only")]
85        agents: bool,
86
87        #[arg(long, help = "Stop MCP servers only")]
88        mcp: bool,
89
90        #[arg(long, help = "Force stop (SIGKILL)")]
91        force: bool,
92    },
93
94    #[command(about = "Restart services")]
95    Restart {
96        #[command(subcommand)]
97        target: Option<RestartTarget>,
98
99        #[arg(long, help = "Restart only failed services")]
100        failed: bool,
101
102        #[arg(long, help = "Restart all agents")]
103        agents: bool,
104
105        #[arg(long, help = "Restart all MCP servers")]
106        mcp: bool,
107    },
108
109    #[command(about = "Show detailed service status")]
110    Status {
111        #[arg(long, help = "Show detailed information")]
112        detailed: bool,
113
114        #[arg(long, help = "Output as JSON")]
115        json: bool,
116
117        #[arg(long, help = "Include health check results")]
118        health: bool,
119    },
120
121    #[command(about = "Clean up orphaned processes and stale entries")]
122    Cleanup {
123        #[arg(short = 'y', long, help = "Skip confirmation prompt")]
124        yes: bool,
125
126        #[arg(long, help = "Preview cleanup without executing")]
127        dry_run: bool,
128    },
129
130    #[command(about = "Start API server (automatically starts agents and MCP servers)")]
131    Serve {
132        #[arg(long, help = "Run in foreground mode")]
133        foreground: bool,
134
135        #[arg(long, help = "Kill process using the port if occupied")]
136        kill_port_process: bool,
137    },
138}
139
140#[derive(Debug, Clone, Subcommand)]
141pub enum RestartTarget {
142    Api,
143    Agent {
144        agent: String,
145    },
146    Mcp {
147        server_name: String,
148        #[arg(long, help = "Rebuild the binary before restarting")]
149        build: bool,
150    },
151}