AtlasRun
一个简单的命令行任务队列管理工具,可以按顺序执行命令。
特性
- 使用简单的命令行接口
- 命令按顺序排队执行
- 每个命令都有唯一编号
- 自动等待前一个命令完成后再执行下一个
- 使用SQLite存储命令队列
- 支持指定工作目录
- 自动创建临时bash脚本
- 进程监控和状态管理
- 任务历史记录和清理
安装
从源码安装
# 克隆仓库
git clone <repository-url>
cd atlasrun
# 安装依赖
pip install -r requirements.txt
# 安装开发模式
pip install -e .
依赖要求
- Python 3.7+
- click (命令行界面库)
使用方法
基本用法
添加命令到队列:
arun "your command here"
例如:
arun "sleep 10"
arun "echo hello world"
arun "python script.py"
第二个命令会等第一个命令完成后才开始执行。
指定工作目录
arun --dir /path/to/directory "your command"
# 或者
arun -d /path/to/directory "your command"
查看队列状态
arun --status
# 或者
arun -s
列出所有任务
arun --list
# 或者
arun -l
查看任务详情
arun --info <task_id>
# 或者
arun -i <task_id>
清理旧任务
arun --cleanup 7 # 清理7天前的已完成任务
# 或者
arun -c 7
工作原理
-
任务添加: 当您运行
arun "command"时,命令会被添加到SQLite数据库中,状态为pending -
队列检查: 系统检查是否有其他任务正在运行
-
任务执行: 如果没有运行中的任务,系统会:
- 创建临时bash脚本在
~/.atlasrun/TEMP_script/目录 - 切换到指定的工作目录
- 使用
nohup启动命令 - 记录PID和开始时间
- 创建临时bash脚本在
-
等待机制: 如果有其他任务在运行,新任务会等待,直到所有运行中的任务完成
-
状态更新: 任务完成后,状态会更新为
completed或failed
文件结构
~/.atlasrun/
├── tasks.db # SQLite数据库文件
└── TEMP_script/ # 临时脚本目录
└── task_*.sh # 临时bash脚本
数据库结构
任务表包含以下字段:
id: 任务唯一标识符command: 要执行的命令working_dir: 工作目录status: 任务状态 (pending/running/completed/failed)pid: 进程IDcreated_at: 创建时间started_at: 开始时间completed_at: 完成时间exit_code: 退出码
开发
- 克隆仓库
- 安装依赖:
pip install -r requirements.txt - 安装开发模式:
pip install -e . - 运行测试:
python test_atlasrun.py
许可证
Apache License 2.0
贡献
欢迎提交Issue和Pull Request!
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
atlasrun-0.1.0.tar.gz
(19.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
atlasrun-0.1.0-py3-none-any.whl
(20.6 kB
view details)
File details
Details for the file atlasrun-0.1.0.tar.gz.
File metadata
- Download URL: atlasrun-0.1.0.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f6d1c0cb7949312bb1aa8fe1086b275df57866ec453787c05da04e2c136bb09
|
|
| MD5 |
7bfef0f81e7c7e07f606221bdc234cfc
|
|
| BLAKE2b-256 |
7d17d25d3b6ea58b6fb130f3a65fdd6157ffd25bbcdef52c1164df4bca84f8cd
|
File details
Details for the file atlasrun-0.1.0-py3-none-any.whl.
File metadata
- Download URL: atlasrun-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c4c65fe4c0bbc62eddbdc56c75cbb52f931a90057b9db75c33cc259701d385e
|
|
| MD5 |
5795176fb06021e0d38826bb758cca39
|
|
| BLAKE2b-256 |
634da93f30bef2cc0e8d8f056f276469b09c0bdf96c639ee3bca7ad289a26e99
|