aaden-cli 1.6.104 → 1.6.106

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.
@@ -1,10 +1,29 @@
1
1
  #!/bin/bash
2
+ # 确保日结物化守护进程 aaden-gdpdu(PHP/autoWriteGdpdu.php)在跑。`aaden-cli auto-write-gdpdu`、装机脚本 aadensetup.sh、
3
+ # patch/202610031600ensureGdpduDaemon.sh 都调这一个脚本;幂等,重复跑安全。
4
+ #
5
+ # 为什么必须有它:每日数据库备份由日结物化流程 ZBon.php?op=writeCombinedZbonClosing 触发,而这个流程只由该守护进程
6
+ # 循环调用;没有它,csv_* 日结不物化(DSFinV-K 导出缺日结),备份也从不执行(10-03 发现 35 台新店漏装)。
7
+ #
8
+ # 已经在跑就不动;有 systemd 装成服务;没有 systemd(老 WSL)写 /etc/cron.d 每分钟调一次。
9
+ # writeCombinedZbonClosing 内部 select … for update 加锁,重复调用也只会串行处理。
10
+ PW='Innerken322.'
11
+ sudoS(){ echo "$PW" | sudo -S bash -c "$*"; }
12
+ PHP_SCRIPT=/var/www/html/PHP/autoWriteGdpdu.php
13
+ UNIT=/etc/systemd/system/aaden-gdpdu.service
14
+ CRON=/etc/cron.d/aaden-gdpdu
2
15
 
3
- ServiceFileName=/etc/systemd/system/aaden-gdpdu.service
16
+ if [ -n "${AADEN_CLOUD_MODE:-}" ]; then echo "云端模式,跳过"; exit 0; fi
17
+ if [ ! -f "$PHP_SCRIPT" ]; then echo "没有 $PHP_SCRIPT,跳过"; exit 0; fi
18
+ # 只认真正用 php 跑这个脚本的进程(命令行里恰好带着文件名的 tail/grep 之类不算)
19
+ if systemctl is-active --quiet aaden-gdpdu.service 2>/dev/null \
20
+ || pgrep -f '^(/usr/bin/)?php[0-9.]* .*autoWriteGdpdu\.php' >/dev/null; then
21
+ echo "aaden-gdpdu 已在运行,不动"; exit 0
22
+ fi
4
23
 
5
- sudo touch $ServiceFileName
6
- sudo chmod 777 $ServiceFileName
7
- echo -e "
24
+ if [ -d /run/systemd/system ]; then
25
+ TMP=$(mktemp)
26
+ cat > "$TMP" <<EOF
8
27
  [Unit]
9
28
  Description=Gdpdu Service For Aaden
10
29
 
@@ -13,13 +32,27 @@ Type=simple
13
32
  Restart=always
14
33
  RestartSec=1
15
34
  User=root
16
- ExecStart=/usr/bin/php /var/www/html/PHP/autoWriteGdpdu.php
35
+ ExecStart=/usr/bin/php $PHP_SCRIPT
17
36
 
18
37
  [Install]
19
38
  WantedBy=multi-user.target
20
- " > $ServiceFileName
39
+ EOF
40
+ sudoS "install -m 644 '$TMP' '$UNIT' && systemctl daemon-reload && systemctl enable --now aaden-gdpdu.service"
41
+ rm -f "$TMP"
42
+ sleep 3
43
+ if systemctl is-active --quiet aaden-gdpdu.service; then
44
+ echo "aaden-gdpdu 已装成 systemd 服务并启动"; exit 0
45
+ fi
46
+ echo "aaden-gdpdu 服务没起来,下次重试"; systemctl status aaden-gdpdu.service --no-pager 2>&1 | tail -5; exit 1
47
+ fi
21
48
 
22
- sudo systemctl start aaden-gdpdu.service
23
- sudo systemctl enable aaden-gdpdu.service
24
- echo 'gdpdu auto write start'
25
- sudo service aaden-gdpdu start
49
+ # 没有 systemd:由 cron 每分钟调一次(和守护进程循环做的是同一件事)
50
+ TMP=$(mktemp)
51
+ cat > "$TMP" <<'EOF'
52
+ # aaden-cli auto-write-gdpdu(AadenDeploy/Utils/writeGdpduService.sh):没有 systemd 的设备由 cron 代替 aaden-gdpdu 守护进程
53
+ * * * * * root flock -n /var/tmp/aaden-gdpdu.lock sh -c 'curl -s -o /dev/null --max-time 900 "http://localhost/PHP/ZBon.php?op=writeCombinedZbonClosing"; curl -s -o /dev/null --max-time 300 "http://localhost/PHP/ZBon.php?op=writeZbonLiteral&countLimit=10"'
54
+ EOF
55
+ sudoS "install -m 644 '$TMP' '$CRON'"
56
+ rm -f "$TMP"
57
+ echo "没有 systemd,已写入 $CRON(每分钟一次)"
58
+ exit 0
@@ -147,6 +147,8 @@ cd /var/www/html/PHP || exit
147
147
  vendor/bin/phinx migrate
148
148
 
149
149
  aaden-cli patch
150
+ # 日结物化守护进程:每日数据库备份和 DSFinV-K 日结物化都靠它(以前漏在装机脚本外,靠手动补)
151
+ aaden-cli auto-write-gdpdu
150
152
  aaden-cli fix-cronjob
151
153
  aaden-cli upgrade
152
154
  aaden-cli update-ngrok-config $DeviceId
@@ -12,7 +12,9 @@ export PATH="/usr/local/bin:$PATH"
12
12
  mkdir -p /etc/aaden/config
13
13
  chmod -R 777 /etc/aaden/config
14
14
 
15
- sudo rm -rf /usr/local/lib/node_modules/.aaden-cli-P0eVNKj8
15
+ # npm 全局重装会先把旧目录改名成 .aaden-cli-<随机串>;上次失败留下的这种目录会让之后每次都 ENOTEMPTY 失败,
16
+ # CLI 永远停在老版本(10-03 车队里有几台卡在 1.6.88~1.6.98)。以前这里只删一个写死名字的目录,现在全删。
17
+ sudo rm -rf /usr/local/lib/node_modules/.aaden-cli-*
16
18
  sudo npm i aaden-cli -g
17
19
 
18
20
  aaden-cli patch
package/dist/index.js CHANGED
@@ -18577,7 +18577,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.19.2","description":"P
18577
18577
  /***/ ((module) => {
18578
18578
 
18579
18579
  "use strict";
18580
- module.exports = {"i8":"1.6.104"};
18580
+ module.exports = {"i8":"1.6.106"};
18581
18581
 
18582
18582
  /***/ })
18583
18583
 
@@ -19254,7 +19254,9 @@ async function appCenterUsage(force) {
19254
19254
  return
19255
19255
  }
19256
19256
  const deviceId = await getCurrentDeviceId()
19257
- if (parseInt(deviceId) === -1) {
19257
+ // 开机时 @reboot 跑 auto-upgrade,本机 PHP 可能还没起来,拿到的是空串 / -1:这次跳过,不写 stamp,下次再报
19258
+ if (!(parseInt(deviceId) > 0)) {
19259
+ console.log('appcenter-usage: 取不到设备号(本机 PHP 可能还没起来),跳过')
19258
19260
  return
19259
19261
  }
19260
19262
  const script = path.join(findMe(), '..', 'AadenDeploy', 'appCenterUsage.py')
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ # 一次性修复:日结物化守护进程 aaden-gdpdu 以前不在装机脚本里(要手动 aaden-cli auto-write-gdpdu),
3
+ # 2025 下半年起漏装的店既没日结物化(DSFinV-K 导出缺日结)、每日数据库备份也从没跑过。
4
+ # 逻辑在 AadenDeploy/Utils/writeGdpduService.sh(已在跑跳过 / 有 systemd 装服务 / 没有 systemd 写 cron)。
5
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6
+ bash "$ROOT/AadenDeploy/Utils/writeGdpduService.sh"
package/index.js CHANGED
@@ -603,7 +603,9 @@ async function appCenterUsage(force) {
603
603
  return
604
604
  }
605
605
  const deviceId = await getCurrentDeviceId()
606
- if (parseInt(deviceId) === -1) {
606
+ // 开机时 @reboot 跑 auto-upgrade,本机 PHP 可能还没起来,拿到的是空串 / -1:这次跳过,不写 stamp,下次再报
607
+ if (!(parseInt(deviceId) > 0)) {
608
+ console.log('appcenter-usage: 取不到设备号(本机 PHP 可能还没起来),跳过')
607
609
  return
608
610
  }
609
611
  const script = path.join(findMe(), '..', 'AadenDeploy', 'appCenterUsage.py')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aaden-cli",
3
- "version": "1.6.104",
3
+ "version": "1.6.106",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ # 一次性修复:日结物化守护进程 aaden-gdpdu 以前不在装机脚本里(要手动 aaden-cli auto-write-gdpdu),
3
+ # 2025 下半年起漏装的店既没日结物化(DSFinV-K 导出缺日结)、每日数据库备份也从没跑过。
4
+ # 逻辑在 AadenDeploy/Utils/writeGdpduService.sh(已在跑跳过 / 有 systemd 装服务 / 没有 systemd 写 cron)。
5
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6
+ bash "$ROOT/AadenDeploy/Utils/writeGdpduService.sh"