发布服务命令行工具(stacli)基于发布服务器的WEB管理接口而开发。命令行整体格式:
xxxxxxxxxx
141stacli [options] <command> [<cmd-args>]
2options:
3 --help
4 --staging-server=<address[:<port>]>]
5 -u, --user=<name[:password]>
6 --version
7 -d, --work-dir=<path>
8
9commands:
10 export
11 import
12 list
13 remove
14 sync
"options" - 全局工作参数
可以输入连接的发布服务地址及管理端口,登录用的用户名和密码
“--work-dir” 工作目录,可选;系统会尝试读取工作目录下的 conf/config.json,该文件可以提供登录相关的参数。
xxxxxxxxxx
101{
2 "user": {
3 "name": "admin",
4 "password": "iguard"
5 },
6 "staging": {
7 "server": "127.0.0.1",
8 "port": 39999
9 }
10}
命令行上的参数优先。
目前的管理工具实现了部分功能:
命令行:
xxxxxxxxxx
11stacli.exe export -C sync-formula --file=<output filename>
参数:
“--file" 指定输出文件,不提供时,内容打印在标准输出上。
内容是json格式的,如下是一个导出例子:
xxxxxxxxxx
681{
2 "sites": [
3 {
4 "name": "s1",
5 "desc": "",
6 "servers": [
7 {
8 "address": "127.0.0.1",
9 "port": 37777
10 }
11 ],
12 "dirmaps": [
13 {
14 "src": "E:\\test\\htdocs",
15 "dst": "F:\\Apache22\\htdocs",
16 "autosync": true
17 },
18 {
19 "src": "E:\\test\\src",
20 "dst": "E:\\test\\dst",
21 "autosync": true
22 },
23 {
24 "src": "E:\\var\\src",
25 "dst": "E:\\kkkdir",
26 "autosync": true
27 }
28 ],
29 "filters": [
30 "- 'E:\\test\\src\\d12\\'"
31 ]
32 },
33 {
34 "name": "s19",
35 "desc": "",
36 "servers": [
37 ],
38 "dirmaps": [
39 {
40 "src": "E:\\test\\src",
41 "dst": "E:\\test\\dst",
42 "autosync": true
43 }
44 ],
45 "filters": [
46 "- 'E:\\test\\src\\d12\\'"
47 ]
48 }
49 ],
50 "servers": [
51 {
52 "name": "h1",
53 "address": "127.0.0.1",
54 "port": 37777,
55 "usessl": true,
56 "threadnum": 0,
57 "desc": ""
58 },
59 {
60 "name": "h2",
61 "address": "192.168.120.7",
62 "port": 37777,
63 "usessl": true,
64 "threadnum": 0,
65 "desc": ""
66 }
67 ]
68}
命令行:
xxxxxxxxxx
11stacli.exe import -C sync-formula --file=<output filename>
"--file" 指定导入内容,格式同导出结果
导入操作会创建站点和服务器,站点的以"name"为依据,同名的会被覆盖;服务器以"address"和"port"的组合为依据(命令行操作时的服务器标识),已存在服务器的内容会被更新。导入操作会先检查根节点下的服务器列表"servers",进行创建或更新;站点"sites"列表中的“servers"里的服务器,如果不存在,也会尝试创建。创建服务器时,如果服务器“name”属性不存在,系统自动分配一个名称:"address"+字母'P'+"port"。根节点下的"servers"允许不存在。
导入后,即刻生效。
xxxxxxxxxx
91stacli.exe sync
2--action=<update|clone>
3--site-name=<name>
4--sync-server=<address[:<port>]>
5--path=<path>
6--filter=<filter>
7--force-expand-dir=<1|0>
8--only-within-filter=<1|0>
9--strict-dir-tree-check=<1|0>
"--path" 同步的文件路径,可以出现多个这样的参数
"--filter" 同步用的过滤规则字符串,可以出现多个这样的参数,规则串的格式请参考相关说明。
创建成功时,返回一个手工同步工作id,这个id是批处理任务号,与单条的文件同步任务号不一样。
手工同步加筛选器举例:
test
的源目录 /usr/local/test
做条件同步 xxxxxxxxxx
11stacli --staging-server=127.0.0.1:39999 -u admin:iguard sync --action=update --site-name=test --path=/usr/local/test/ --sync-server=127.0.0.1:37777 "--filter=+'*' time(2021-10-31 00:00:00,2021-11-01 23:59:59)" --only-within-filter=1
test
的 源目录 /usr/local/test
对三天以内的变更的文件做条件同步 ,可以结合conrtab 定时执行。xxxxxxxxxx
11stacli --staging-server=127.0.0.1:39999 -u admin:iguard sync --action=update --site-name=test --path=/usr/local/test/ --sync-server=127.0.0.1:37777 "--filter=+'*' time(`date +"%Y-%m-%d" -d "-3 day"` 00:00:00,`date +"%Y-%m-%d"` 23:59:59)" --only-within-filter=1
根据工作id(批处理任务号)来查询状态
xxxxxxxxxx
11stacli.exe sync --stat=<job id>
xxxxxxxxxx
11stacli.exe list -C task --site-name=s1 --sync-server=127.0.0.1:37777
--site-name
站点名称
--sync-server
服务器标识
输出结果:
xxxxxxxxxx
161--------------
2tid,created_on,action,src
3--------------
436738,2019-04-24 16:41:12,UPLOAD,E:/test/src/ptest.c
536739,2019-04-24 16:41:12,UPLOAD,E:/test/src/rain.c
636740,2019-04-24 16:41:12,UPLOAD,E:/test/src/README.md
736741,2019-04-24 16:41:12,UPLOAD,E:/test/src/testcurs.c
836742,2019-04-24 16:41:12,UPLOAD,E:/test/src/tui.c
936743,2019-04-24 16:41:12,UPLOAD,E:/test/src/tui.h
1036744,2019-04-24 16:41:12,UPLOAD,E:/test/src/tuidemo.c
1136745,2019-04-24 16:41:12,UPLOAD,E:/test/src/worm.c
1236746,2019-04-24 16:41:12,UPLOAD,E:/test/src/xmas.c
1336747,2019-04-24 16:41:12,UPLOAD,E:/test/src/firework.c
1436748,2019-04-24 16:41:12,UPLOAD,E:/test/src/nctests.mif
1536749,2019-04-24 16:41:12,UPLOAD,E:/test/src/ncurses_cfg.h
1636750,2019-04-24 16:41:14,UPLOAD,E:/test/src/ozdemo.c
返回结果中的 tid列为文件同步任务编号。
xxxxxxxxxx
21stacli.exe remove -C task --site-name=s1 --sync-server=127.0.0.1:37777 \
2 --tids=36749,36750
参数:
"--tids" 指定需要删除的文件同步任务编号列表,用逗号,
分隔;这个和手工同步请求返回的工作id不一样。
修改命令行登录账户的密码
xxxxxxxxxx
11stacli.exe passwd [--new-password=<new password>]
参数
“--new-password” 指定新密码,可选;如果没有指定,会在命令行界面上提示输入。
许可证操作有注册、激活和查看,搭配不同的参数组合来实现
xxxxxxxxxx
11stacli.exe register [user] [key] [--regfile=<filename>] [--actcode=<activation code>]
注册使用许可,需要提供用户名(user)和许可证注册码(key),可以在 register 命令后按序输入,可以保存在文件中通过参数"--regfile"输入,文件内容为json数据格式:
xxxxxxxxxx
41{
2 "user":"demo",
3 "key":"XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
4}
许可注册完成后,通过"---actcode"输入激活码进行许可证激活操作
在不提供注册或激活参数时,进行许可证查看操作。
xxxxxxxxxx
11stacli.exe list -C task-status
xxxxxxxxxx
31stacli.exe list -C <syslog|translog|alertlog|ftasklog> \
2 [--date=2019-04-25] \
3 [--tokens=“abc 123”]
"--date" 指定日志日期,可选;缺省为当天。
“--tokens" 筛选日志,指定包含的字串