servly 0.1.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- servly-0.3.0/PKG-INFO +134 -0
- servly-0.3.0/README.md +119 -0
- {servly-0.1.0 → servly-0.3.0}/pyproject.toml +12 -3
- servly-0.3.0/servly/__init__.py +5 -0
- servly-0.3.0/servly/cli.py +270 -0
- servly-0.3.0/servly/logs.py +226 -0
- servly-0.3.0/servly/service.py +215 -0
- servly-0.3.0/servly.egg-info/PKG-INFO +134 -0
- servly-0.3.0/servly.egg-info/SOURCES.txt +17 -0
- servly-0.3.0/servly.egg-info/entry_points.txt +2 -0
- servly-0.3.0/servly.egg-info/requires.txt +2 -0
- servly-0.3.0/servly.egg-info/top_level.txt +1 -0
- servly-0.3.0/tests/test_advanced.py +310 -0
- servly-0.3.0/tests/test_config.py +51 -0
- servly-0.3.0/tests/test_integration.py +275 -0
- servly-0.3.0/tests/test_logs.py +110 -0
- servly-0.3.0/tests/test_service_management.py +121 -0
- servly-0.1.0/PKG-INFO +0 -14
- servly-0.1.0/README.md +0 -1
- servly-0.1.0/servly.egg-info/PKG-INFO +0 -14
- servly-0.1.0/servly.egg-info/SOURCES.txt +0 -9
- servly-0.1.0/servly.egg-info/entry_points.txt +0 -2
- servly-0.1.0/servly.egg-info/top_level.txt +0 -1
- servly-0.1.0/xm/__init__.py +0 -1
- servly-0.1.0/xm/cli.py +0 -7
- {servly-0.1.0 → servly-0.3.0}/servly.egg-info/dependency_links.txt +0 -0
- {servly-0.1.0 → servly-0.3.0}/setup.cfg +0 -0
servly-0.3.0/PKG-INFO
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: servly
|
3
|
+
Version: 0.3.0
|
4
|
+
Summary: simple process manager
|
5
|
+
Author-email: simpxx <simpxx@gmail.com>
|
6
|
+
License: MIT
|
7
|
+
Keywords: command-line,tool
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Requires-Python: >=3.12
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
Requires-Dist: pyyaml>=6.0.2
|
14
|
+
Requires-Dist: rich>=14.0.0
|
15
|
+
|
16
|
+
# SERVLY
|
17
|
+
|
18
|
+
A simple process management tool for Linux, similar to PM2, designed to simplify application deployment and management.
|
19
|
+
|
20
|
+
## Features
|
21
|
+
|
22
|
+
- Start, stop, and restart services defined in a `servly.yml` configuration file
|
23
|
+
- View real-time logs with service name highlighting
|
24
|
+
- Automatic process supervision and PID management
|
25
|
+
- Environment variable support
|
26
|
+
- Simple YAML configuration
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
```bash
|
31
|
+
# Using pip
|
32
|
+
pip install servly
|
33
|
+
|
34
|
+
# From source
|
35
|
+
git clone https://github.com/yourusername/servly.git
|
36
|
+
cd servly
|
37
|
+
pip install -e .
|
38
|
+
```
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
### Quick Start
|
43
|
+
|
44
|
+
1. Create a `servly.yml` file in your project:
|
45
|
+
|
46
|
+
```yaml
|
47
|
+
# Basic format: service-name: command
|
48
|
+
web-server: node server.js
|
49
|
+
|
50
|
+
# Detailed format
|
51
|
+
api:
|
52
|
+
cmd: python api.py
|
53
|
+
cwd: ./api
|
54
|
+
env:
|
55
|
+
NODE_ENV: production
|
56
|
+
```
|
57
|
+
|
58
|
+
2. Start your services:
|
59
|
+
|
60
|
+
```bash
|
61
|
+
servly start
|
62
|
+
```
|
63
|
+
|
64
|
+
### Core Commands
|
65
|
+
|
66
|
+
- **Start Services**:
|
67
|
+
```bash
|
68
|
+
servly start [all | service-name]
|
69
|
+
```
|
70
|
+
Starts all services or a specific service by name.
|
71
|
+
|
72
|
+
- **Stop Services**:
|
73
|
+
```bash
|
74
|
+
servly stop [all | service-name]
|
75
|
+
```
|
76
|
+
Stops all running services or a specific service by name.
|
77
|
+
|
78
|
+
- **Restart Services**:
|
79
|
+
```bash
|
80
|
+
servly restart [all | service-name]
|
81
|
+
```
|
82
|
+
Restarts all services or a specific service by name.
|
83
|
+
|
84
|
+
- **View Service Logs**:
|
85
|
+
```bash
|
86
|
+
servly log [all | service-name]
|
87
|
+
```
|
88
|
+
Shows logs in real-time (similar to `tail -f`).
|
89
|
+
|
90
|
+
- **List Services**:
|
91
|
+
```bash
|
92
|
+
servly list
|
93
|
+
```
|
94
|
+
Shows status of all configured services.
|
95
|
+
|
96
|
+
## Configuration
|
97
|
+
|
98
|
+
### servly.yml
|
99
|
+
|
100
|
+
The `servly.yml` file supports two formats:
|
101
|
+
|
102
|
+
1. **Simple format**:
|
103
|
+
```yaml
|
104
|
+
service-name: command to run
|
105
|
+
```
|
106
|
+
|
107
|
+
2. **Detailed format**:
|
108
|
+
```yaml
|
109
|
+
service-name:
|
110
|
+
cmd: command to run
|
111
|
+
cwd: working directory (optional)
|
112
|
+
env:
|
113
|
+
ENV_VAR1: value1
|
114
|
+
ENV_VAR2: value2
|
115
|
+
```
|
116
|
+
|
117
|
+
**Note**: The name "servly" is reserved and cannot be used as a service name.
|
118
|
+
|
119
|
+
### Directory Structure
|
120
|
+
|
121
|
+
Servly creates a `.servly` directory to store runtime information:
|
122
|
+
|
123
|
+
```
|
124
|
+
.servly/
|
125
|
+
├── logs/
|
126
|
+
│ ├── [service-name]-out.log # Standard output logs
|
127
|
+
│ └── [service-name]-error.log # Error logs
|
128
|
+
├── pids/
|
129
|
+
│ └── [service-name].pid # Process ID files
|
130
|
+
```
|
131
|
+
|
132
|
+
## License
|
133
|
+
|
134
|
+
MIT
|
servly-0.3.0/README.md
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
# SERVLY
|
2
|
+
|
3
|
+
A simple process management tool for Linux, similar to PM2, designed to simplify application deployment and management.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- Start, stop, and restart services defined in a `servly.yml` configuration file
|
8
|
+
- View real-time logs with service name highlighting
|
9
|
+
- Automatic process supervision and PID management
|
10
|
+
- Environment variable support
|
11
|
+
- Simple YAML configuration
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
```bash
|
16
|
+
# Using pip
|
17
|
+
pip install servly
|
18
|
+
|
19
|
+
# From source
|
20
|
+
git clone https://github.com/yourusername/servly.git
|
21
|
+
cd servly
|
22
|
+
pip install -e .
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
### Quick Start
|
28
|
+
|
29
|
+
1. Create a `servly.yml` file in your project:
|
30
|
+
|
31
|
+
```yaml
|
32
|
+
# Basic format: service-name: command
|
33
|
+
web-server: node server.js
|
34
|
+
|
35
|
+
# Detailed format
|
36
|
+
api:
|
37
|
+
cmd: python api.py
|
38
|
+
cwd: ./api
|
39
|
+
env:
|
40
|
+
NODE_ENV: production
|
41
|
+
```
|
42
|
+
|
43
|
+
2. Start your services:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
servly start
|
47
|
+
```
|
48
|
+
|
49
|
+
### Core Commands
|
50
|
+
|
51
|
+
- **Start Services**:
|
52
|
+
```bash
|
53
|
+
servly start [all | service-name]
|
54
|
+
```
|
55
|
+
Starts all services or a specific service by name.
|
56
|
+
|
57
|
+
- **Stop Services**:
|
58
|
+
```bash
|
59
|
+
servly stop [all | service-name]
|
60
|
+
```
|
61
|
+
Stops all running services or a specific service by name.
|
62
|
+
|
63
|
+
- **Restart Services**:
|
64
|
+
```bash
|
65
|
+
servly restart [all | service-name]
|
66
|
+
```
|
67
|
+
Restarts all services or a specific service by name.
|
68
|
+
|
69
|
+
- **View Service Logs**:
|
70
|
+
```bash
|
71
|
+
servly log [all | service-name]
|
72
|
+
```
|
73
|
+
Shows logs in real-time (similar to `tail -f`).
|
74
|
+
|
75
|
+
- **List Services**:
|
76
|
+
```bash
|
77
|
+
servly list
|
78
|
+
```
|
79
|
+
Shows status of all configured services.
|
80
|
+
|
81
|
+
## Configuration
|
82
|
+
|
83
|
+
### servly.yml
|
84
|
+
|
85
|
+
The `servly.yml` file supports two formats:
|
86
|
+
|
87
|
+
1. **Simple format**:
|
88
|
+
```yaml
|
89
|
+
service-name: command to run
|
90
|
+
```
|
91
|
+
|
92
|
+
2. **Detailed format**:
|
93
|
+
```yaml
|
94
|
+
service-name:
|
95
|
+
cmd: command to run
|
96
|
+
cwd: working directory (optional)
|
97
|
+
env:
|
98
|
+
ENV_VAR1: value1
|
99
|
+
ENV_VAR2: value2
|
100
|
+
```
|
101
|
+
|
102
|
+
**Note**: The name "servly" is reserved and cannot be used as a service name.
|
103
|
+
|
104
|
+
### Directory Structure
|
105
|
+
|
106
|
+
Servly creates a `.servly` directory to store runtime information:
|
107
|
+
|
108
|
+
```
|
109
|
+
.servly/
|
110
|
+
├── logs/
|
111
|
+
│ ├── [service-name]-out.log # Standard output logs
|
112
|
+
│ └── [service-name]-error.log # Error logs
|
113
|
+
├── pids/
|
114
|
+
│ └── [service-name].pid # Process ID files
|
115
|
+
```
|
116
|
+
|
117
|
+
## License
|
118
|
+
|
119
|
+
MIT
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "servly"
|
7
|
-
version = "0.
|
7
|
+
version = "0.3.0"
|
8
8
|
description = "simple process manager"
|
9
9
|
readme = "README.md"
|
10
10
|
requires-python = ">=3.12"
|
@@ -18,9 +18,18 @@ classifiers = [
|
|
18
18
|
"License :: OSI Approved :: MIT License",
|
19
19
|
"Operating System :: OS Independent",
|
20
20
|
]
|
21
|
+
dependencies = [
|
22
|
+
"pyyaml>=6.0.2",
|
23
|
+
"rich>=14.0.0",
|
24
|
+
]
|
21
25
|
|
22
26
|
[project.scripts]
|
23
|
-
|
27
|
+
servly = "servly.cli:main"
|
24
28
|
|
25
29
|
[tool.setuptools.packages.find]
|
26
|
-
include = ["
|
30
|
+
include = ["servly*"]
|
31
|
+
|
32
|
+
[dependency-groups]
|
33
|
+
dev = [
|
34
|
+
"pytest>=8.3.5",
|
35
|
+
]
|
@@ -0,0 +1,270 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
Command-line interface for Servly process manager.
|
4
|
+
使用Rich库进行终端输出格式化
|
5
|
+
"""
|
6
|
+
import os
|
7
|
+
import sys
|
8
|
+
import argparse
|
9
|
+
import logging
|
10
|
+
from pathlib import Path
|
11
|
+
from typing import List, Dict, Optional
|
12
|
+
|
13
|
+
from servly.service import ServiceManager
|
14
|
+
from servly.logs import LogManager, Emojis
|
15
|
+
from servly.logs import console, print_header, print_info, print_warning, print_error, print_success, print_service_table
|
16
|
+
|
17
|
+
from rich.logging import RichHandler
|
18
|
+
from rich.traceback import install
|
19
|
+
from rich.markup import escape
|
20
|
+
|
21
|
+
# 安装Rich的异常格式化器
|
22
|
+
install()
|
23
|
+
|
24
|
+
# 配置Rich日志处理
|
25
|
+
logging.basicConfig(
|
26
|
+
level=logging.INFO,
|
27
|
+
format="%(message)s",
|
28
|
+
datefmt="[%X]",
|
29
|
+
handlers=[RichHandler(rich_tracebacks=True, markup=True)]
|
30
|
+
)
|
31
|
+
|
32
|
+
logger = logging.getLogger("servly")
|
33
|
+
|
34
|
+
def setup_arg_parser() -> argparse.ArgumentParser:
|
35
|
+
"""设置命令行参数解析器"""
|
36
|
+
parser = argparse.ArgumentParser(
|
37
|
+
description=f"{Emojis.SERVICE} Servly - Modern process manager",
|
38
|
+
formatter_class=argparse.RawDescriptionHelpFormatter
|
39
|
+
)
|
40
|
+
|
41
|
+
# 全局参数
|
42
|
+
parser.add_argument('-f', '--config',
|
43
|
+
help='配置文件路径 (默认: servly.yml)',
|
44
|
+
default='servly.yml')
|
45
|
+
|
46
|
+
subparsers = parser.add_subparsers(dest='command', help='要执行的命令')
|
47
|
+
|
48
|
+
# Start 命令
|
49
|
+
start_parser = subparsers.add_parser('start', help=f'{Emojis.START} 启动服务')
|
50
|
+
start_parser.add_argument('service', nargs='?', default='all',
|
51
|
+
help='服务名称或 "all" 启动所有服务')
|
52
|
+
|
53
|
+
# Stop 命令
|
54
|
+
stop_parser = subparsers.add_parser('stop', help=f'{Emojis.STOP} 停止服务')
|
55
|
+
stop_parser.add_argument('service', nargs='?', default='all',
|
56
|
+
help='服务名称或 "all" 停止所有服务')
|
57
|
+
|
58
|
+
# Restart 命令
|
59
|
+
restart_parser = subparsers.add_parser('restart', help=f'{Emojis.RESTART} 重启服务')
|
60
|
+
restart_parser.add_argument('service', nargs='?', default='all',
|
61
|
+
help='服务名称或 "all" 重启所有服务')
|
62
|
+
|
63
|
+
# Log 命令
|
64
|
+
log_parser = subparsers.add_parser('log', help=f'{Emojis.LOG} 查看服务日志')
|
65
|
+
log_parser.add_argument('service', nargs='?', default='all',
|
66
|
+
help='服务名称或 "all" 查看所有日志')
|
67
|
+
log_parser.add_argument('--no-follow', '-n', action='store_true',
|
68
|
+
help='不实时跟踪日志')
|
69
|
+
log_parser.add_argument('--lines', '-l', type=int, default=10,
|
70
|
+
help='初始显示的行数')
|
71
|
+
|
72
|
+
# List 命令 - 保留原命令名,不改为 ps
|
73
|
+
list_parser = subparsers.add_parser('list', help='列出服务')
|
74
|
+
|
75
|
+
return parser
|
76
|
+
|
77
|
+
def handle_start(manager: ServiceManager, service_name: str) -> bool:
|
78
|
+
"""处理启动命令"""
|
79
|
+
if service_name == 'all':
|
80
|
+
service_names = manager.get_service_names()
|
81
|
+
if not service_names:
|
82
|
+
print_warning("配置中没有定义任何服务。")
|
83
|
+
return False
|
84
|
+
|
85
|
+
console.print(f"{Emojis.START} 正在启动所有服务...", style="running")
|
86
|
+
success = True
|
87
|
+
for name in service_names:
|
88
|
+
if not manager.start(name):
|
89
|
+
print_error(f"启动服务 '{name}' 失败")
|
90
|
+
success = False
|
91
|
+
else:
|
92
|
+
print_success(f"服务 '{name}' 已成功启动")
|
93
|
+
|
94
|
+
if success:
|
95
|
+
print_success("所有服务已成功启动!")
|
96
|
+
else:
|
97
|
+
print_warning("有些服务启动失败,请检查日志获取详情。")
|
98
|
+
|
99
|
+
return success
|
100
|
+
else:
|
101
|
+
result = manager.start(service_name)
|
102
|
+
if result:
|
103
|
+
print_success(f"服务 '{service_name}' 已成功启动")
|
104
|
+
else:
|
105
|
+
print_error(f"启动服务 '{service_name}' 失败")
|
106
|
+
return result
|
107
|
+
|
108
|
+
def handle_stop(manager: ServiceManager, service_name: str) -> bool:
|
109
|
+
"""处理停止命令"""
|
110
|
+
if service_name == 'all':
|
111
|
+
service_names = manager.get_running_services()
|
112
|
+
if not service_names:
|
113
|
+
console.print(f"{Emojis.INFO} 当前没有正在运行的服务。", style="dim")
|
114
|
+
return True
|
115
|
+
|
116
|
+
console.print(f"{Emojis.STOP} 正在停止所有服务...", style="warning")
|
117
|
+
success = True
|
118
|
+
for name in service_names:
|
119
|
+
if not manager.stop(name):
|
120
|
+
print_error(f"停止服务 '{name}' 失败")
|
121
|
+
success = False
|
122
|
+
else:
|
123
|
+
console.print(f"{Emojis.STOPPED} 服务 '{name}' 已停止", style="stopped")
|
124
|
+
|
125
|
+
if success:
|
126
|
+
console.print(f"\n{Emojis.STOPPED} 所有服务已成功停止!", style="warning")
|
127
|
+
else:
|
128
|
+
print_warning("有些服务停止失败,请检查日志获取详情。")
|
129
|
+
|
130
|
+
return success
|
131
|
+
else:
|
132
|
+
result = manager.stop(service_name)
|
133
|
+
if result:
|
134
|
+
console.print(f"{Emojis.STOPPED} 服务 '{service_name}' 已成功停止", style="warning")
|
135
|
+
else:
|
136
|
+
print_error(f"停止服务 '{service_name}' 失败")
|
137
|
+
return result
|
138
|
+
|
139
|
+
def handle_restart(manager: ServiceManager, service_name: str) -> bool:
|
140
|
+
"""处理重启命令"""
|
141
|
+
if service_name == 'all':
|
142
|
+
service_names = manager.get_service_names()
|
143
|
+
if not service_names:
|
144
|
+
print_warning("配置中没有定义任何服务。")
|
145
|
+
return False
|
146
|
+
|
147
|
+
console.print(f"{Emojis.RESTART} 正在重启所有服务...", style="restart")
|
148
|
+
success = True
|
149
|
+
for name in service_names:
|
150
|
+
if not manager.restart(name):
|
151
|
+
print_error(f"重启服务 '{name}' 失败")
|
152
|
+
success = False
|
153
|
+
else:
|
154
|
+
console.print(f"{Emojis.RUNNING} 服务 '{name}' 已成功重启", style="restart")
|
155
|
+
|
156
|
+
if success:
|
157
|
+
print_success("所有服务已成功重启!")
|
158
|
+
else:
|
159
|
+
print_warning("有些服务重启失败,请检查日志获取详情。")
|
160
|
+
|
161
|
+
return success
|
162
|
+
else:
|
163
|
+
result = manager.restart(service_name)
|
164
|
+
if result:
|
165
|
+
console.print(f"{Emojis.RUNNING} 服务 '{service_name}' 已成功重启", style="restart")
|
166
|
+
else:
|
167
|
+
print_error(f"重启服务 '{service_name}' 失败")
|
168
|
+
return result
|
169
|
+
|
170
|
+
def handle_log(manager: ServiceManager, log_manager: LogManager, args) -> bool:
|
171
|
+
"""处理日志查看命令"""
|
172
|
+
service_name = args.service
|
173
|
+
follow = not args.no_follow
|
174
|
+
lines = args.lines
|
175
|
+
|
176
|
+
if service_name == 'all':
|
177
|
+
services = manager.get_service_names()
|
178
|
+
if not services:
|
179
|
+
print_warning("配置中没有定义任何服务。")
|
180
|
+
return False
|
181
|
+
else:
|
182
|
+
if service_name not in manager.get_service_names():
|
183
|
+
print_error(f"服务 '{service_name}' 在配置中未找到。")
|
184
|
+
return False
|
185
|
+
services = [service_name]
|
186
|
+
|
187
|
+
# 使用LogManager查看日志
|
188
|
+
log_manager.tail_logs(services, follow=follow, lines=lines)
|
189
|
+
return True
|
190
|
+
|
191
|
+
def handle_list(manager: ServiceManager) -> bool:
|
192
|
+
"""处理列出服务命令"""
|
193
|
+
service_names = manager.get_service_names()
|
194
|
+
|
195
|
+
if not service_names:
|
196
|
+
print_warning("配置中没有定义任何服务。")
|
197
|
+
return True
|
198
|
+
|
199
|
+
print_header("服务列表")
|
200
|
+
|
201
|
+
# 构建服务列表数据
|
202
|
+
services = []
|
203
|
+
for name in service_names:
|
204
|
+
is_running = manager.is_running(name)
|
205
|
+
pid = manager.get_service_pid(name)
|
206
|
+
|
207
|
+
services.append({
|
208
|
+
"name": name,
|
209
|
+
"status": "running" if is_running else "stopped",
|
210
|
+
"pid": pid
|
211
|
+
})
|
212
|
+
|
213
|
+
# 使用Rich表格显示服务列表
|
214
|
+
print_service_table(services)
|
215
|
+
|
216
|
+
console.print(f"[dim]配置文件: {manager.config_path}[/]")
|
217
|
+
console.print(f"[dim]运行中服务: {len(manager.get_running_services())}/{len(service_names)}[/]")
|
218
|
+
console.print()
|
219
|
+
|
220
|
+
return True
|
221
|
+
|
222
|
+
def main():
|
223
|
+
"""CLI 应用程序入口点"""
|
224
|
+
# 显示头部
|
225
|
+
print_header("SERVLY - Modern Process Manager")
|
226
|
+
|
227
|
+
parser = setup_arg_parser()
|
228
|
+
args = parser.parse_args()
|
229
|
+
|
230
|
+
if not args.command:
|
231
|
+
parser.print_help()
|
232
|
+
return 1
|
233
|
+
|
234
|
+
# 创建服务管理器
|
235
|
+
try:
|
236
|
+
service_manager = ServiceManager(config_path=args.config)
|
237
|
+
except Exception as e:
|
238
|
+
print_error(f"加载配置文件时出错: {escape(str(e))}")
|
239
|
+
return 1
|
240
|
+
|
241
|
+
# 创建日志管理器
|
242
|
+
log_manager = LogManager(service_manager.log_dir)
|
243
|
+
|
244
|
+
# 处理命令
|
245
|
+
try:
|
246
|
+
if args.command == 'start':
|
247
|
+
success = handle_start(service_manager, args.service)
|
248
|
+
elif args.command == 'stop':
|
249
|
+
success = handle_stop(service_manager, args.service)
|
250
|
+
elif args.command == 'restart':
|
251
|
+
success = handle_restart(service_manager, args.service)
|
252
|
+
elif args.command == 'log':
|
253
|
+
success = handle_log(service_manager, log_manager, args)
|
254
|
+
elif args.command == 'list':
|
255
|
+
success = handle_list(service_manager)
|
256
|
+
else:
|
257
|
+
parser.print_help()
|
258
|
+
return 1
|
259
|
+
except KeyboardInterrupt:
|
260
|
+
console.print(f"\n{Emojis.STOP} 操作被用户中断", style="dim")
|
261
|
+
return 1
|
262
|
+
except Exception as e:
|
263
|
+
print_error(f"执行命令时出错: {escape(str(e))}")
|
264
|
+
logger.exception("命令执行异常")
|
265
|
+
return 1
|
266
|
+
|
267
|
+
return 0 if success else 1
|
268
|
+
|
269
|
+
if __name__ == "__main__":
|
270
|
+
sys.exit(main())
|