@leiyi-works/dsh-auto-restart 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/index.js +0 -39
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -77,10 +77,6 @@ const DEFAULTS = Object.freeze({
77
77
  maxIdleWaitMs: 120000,
78
78
  /** 等空闲超时后是否仍然强重启;默认 false(放弃本次,等下次变化)。 */
79
79
  forceWhenBusy: false,
80
- /** 这些标记文件存在时(相对 DSH_HOME),说明有后台任务在跑,先等它结束再重启。 */
81
- busyMarkers: ['.cloud-sync/sync-busy'],
82
- /** 等后台任务结束的最长时间(毫秒),超时按 forceWhenBusy 处理。 */
83
- busyWaitMs: 600000,
84
80
  /** 守护进程收到请求后等多久动手(毫秒),留时间给当前回合收尾。 */
85
81
  restartDelayMs: 2000,
86
82
  /** 重启后把主窗口最大化(开关在左侧「自动重启」面板里)。 */
@@ -113,16 +109,6 @@ function dshHome() {
113
109
  return typeof env === 'string' && env.trim() !== '' ? env.trim() : join(homedir(), '.dsh')
114
110
  }
115
111
 
116
- function activeBusyMarkers(cfg) {
117
- const found = []
118
- for (const rel of cfg.busyMarkers) {
119
- try {
120
- if (existsSync(join(dshHome(), rel))) found.push(rel)
121
- } catch { /* 忽略 */ }
122
- }
123
- return found
124
- }
125
-
126
112
  function dataDir() {
127
113
  return join(dshHome(), 'dsh-auto-restart')
128
114
  }
@@ -234,13 +220,6 @@ function sanitizeConfig(raw) {
234
220
  cfg.dryRun = bool(raw.dryRun, cfg.dryRun)
235
221
  cfg.waitForIdle = bool(raw.waitForIdle, cfg.waitForIdle)
236
222
  cfg.forceWhenBusy = bool(raw.forceWhenBusy, cfg.forceWhenBusy)
237
- cfg.busyWaitMs = num(raw.busyWaitMs, cfg.busyWaitMs, 0, 3600000)
238
- if (Array.isArray(raw.busyMarkers)) {
239
- cfg.busyMarkers = raw.busyMarkers
240
- .filter((item) => typeof item === 'string' && item.trim() !== '')
241
- .slice(0, 8)
242
- .map((item) => item.trim())
243
- }
244
223
  cfg.maximizeOnRestart = bool(raw.maximizeOnRestart, cfg.maximizeOnRestart)
245
224
  cfg.pollIntervalMs = num(raw.pollIntervalMs, cfg.pollIntervalMs, 500, 60000)
246
225
  cfg.stableMs = num(raw.stableMs, cfg.stableMs, 0, 600000)
@@ -549,7 +528,6 @@ function createState(profileDir) {
549
528
  lastChangeAt: 0,
550
529
  pendingSince: 0,
551
530
  waitingSince: 0,
552
- markerWaitingSince: 0,
553
531
  lastRestartAt: persisted.lastRestartAt,
554
532
  restarts: persisted.restarts.filter((t) => now - t < 3600000),
555
533
  lastManagerAt: 0,
@@ -626,23 +604,6 @@ function tick(baseConfig) {
626
604
  return
627
605
  }
628
606
 
629
- const markers = activeBusyMarkers(cfg)
630
- if (markers.length > 0) {
631
- if (state.markerWaitingSince === 0) {
632
- state.markerWaitingSince = now
633
- logLine('info', `检测到进行中的云同步(${markers.join('、')}),等它结束后再重启`)
634
- return
635
- }
636
- if (now - state.markerWaitingSince <= cfg.busyWaitMs) return
637
- if (!cfg.forceWhenBusy) {
638
- abortPending(state, `云同步进行了 ${Math.round(cfg.busyWaitMs / 1000)}s 仍未结束,本次跳过重启`)
639
- return
640
- }
641
- logLine('warn', `云同步超过 ${Math.round(cfg.busyWaitMs / 1000)}s,forceWhenBusy=true,按配置强重启`)
642
- } else if (state.markerWaitingSince !== 0) {
643
- state.markerWaitingSince = 0
644
- }
645
-
646
607
  if (cfg.waitForIdle && state.busy.size > 0) {
647
608
  if (state.waitingSince === 0) {
648
609
  state.waitingSince = now
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@leiyi-works/dsh-auto-restart",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "title": "自动重启",
6
- "description": "装/更插件后自动重启 DSH 并回到原会话:检测 profile 插件文件变化,等所有会话空闲,由脱离进程树的守护者先杀主进程再拉起(可最大化窗口),带冷却、试运行、日志和左侧「自动重启」面板。(0.1.2:云同步进行中(.cloud-sync/sync-busy 标记)自动等待其结束再重启)",
6
+ "description": "装/更插件后自动重启 DSH 并回到原会话:检测 profile 插件文件变化,等所有会话空闲,由脱离进程树的守护者先杀主进程再拉起(可最大化窗口),带冷却、试运行、日志和左侧「自动重启」面板。",
7
7
  "main": "index.js",
8
8
  "exports": {
9
9
  ".": "./index.js",