lightman-agent 1.0.0 → 1.0.2

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.
package/bin/cms-agent.js CHANGED
@@ -8,7 +8,7 @@ import { spawnSync } from 'child_process';
8
8
  import { createInterface } from 'readline/promises';
9
9
  import { stdin as input, stdout as output, cwd, platform, exit } from 'process';
10
10
 
11
- const DEFAULT_SERVER = 'http://192.168.1.181:3401';
11
+ const DEFAULT_SERVER = 'http://192.168.1.100:3401';
12
12
  const INSTALL_CONFIG_PATH = 'C:\\Program Files\\Lightman\\Agent\\agent.config.json';
13
13
 
14
14
  function printUsage() {
@@ -22,7 +22,7 @@ Commands:
22
22
 
23
23
  Options:
24
24
  --slug <value> Device slug (example: C-AV01)
25
- --server <url> Server URL (example: http://192.168.1.181:3401)
25
+ --server <url> Server URL (example: http://192.168.1.100:3401)
26
26
  --timezone <tz> Timezone override (default: Asia/Kolkata)
27
27
  --no-restart Skip reboot after successful install/update
28
28
  -h, --help Show help
@@ -143,8 +143,8 @@ function installUsingPowerShell({ scriptPath, slug, server, timezone, noRestart
143
143
  runOrFail('powershell.exe', args);
144
144
 
145
145
  if (!noRestart) {
146
- console.log('Installation completed. Rebooting in 10 seconds...');
147
- runOrFail('shutdown.exe', ['/r', '/t', '10', '/c', 'CMS Agent installation complete']);
146
+ console.log('Installation completed. Rebooting now...');
147
+ runOrFail('shutdown.exe', ['/r', '/t', '0', '/c', 'CMS Agent installation complete']);
148
148
  }
149
149
  }
150
150
 
@@ -159,7 +159,7 @@ async function runInstall(opts) {
159
159
  const localConfig = safeReadJson(resolve(cwd(), 'agent.config.json')) || {};
160
160
  const installedConfig = safeReadJson(INSTALL_CONFIG_PATH) || {};
161
161
  const defaultSlug = opts.slug || localConfig.deviceSlug || installedConfig.deviceSlug || '';
162
- const server = opts.server || localConfig.serverUrl || installedConfig.serverUrl || DEFAULT_SERVER;
162
+ const server = opts.server || DEFAULT_SERVER;
163
163
  const timezone = opts.timezone || localConfig?.powerSchedule?.timezone || installedConfig?.powerSchedule?.timezone || 'Asia/Kolkata';
164
164
  const noRestart = Boolean(opts.noRestart);
165
165
 
@@ -191,7 +191,7 @@ async function runUpdate(opts) {
191
191
 
192
192
  const installedConfig = safeReadJson(INSTALL_CONFIG_PATH) || {};
193
193
  const slug = opts.slug || installedConfig.deviceSlug;
194
- const server = opts.server || installedConfig.serverUrl || DEFAULT_SERVER;
194
+ const server = opts.server || DEFAULT_SERVER;
195
195
  const timezone = opts.timezone || installedConfig?.powerSchedule?.timezone || 'Asia/Kolkata';
196
196
  const noRestart = Boolean(opts.noRestart);
197
197
  const scriptPath = resolveInstallScript();
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "name": "lightman-agent",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "LIGHTMAN Agent - System-level daemon for museum display machines",
5
5
  "private": false,
6
6
  "type": "module",
7
- "bin": {
8
- "cms-agent": "bin/cms-agent.js",
9
- "lightman-agent": "bin/cms-agent.js"
10
- },
11
- "files": [
12
- "bin/",
13
- "nssm/",
14
- "public/",
15
- "scripts/",
16
- "src/index.ts",
17
- "src/commands/",
18
- "src/lib/",
19
- "src/services/",
20
- "agent.config.template.json",
21
- "package-lock.json",
22
- "tsconfig.json"
23
- ],
24
- "publishConfig": {
25
- "access": "public"
26
- },
27
- "scripts": {
7
+ "bin": {
8
+ "cms-agent": "bin/cms-agent.js",
9
+ "lightman-agent": "bin/cms-agent.js"
10
+ },
11
+ "files": [
12
+ "bin/",
13
+ "nssm/",
14
+ "public/",
15
+ "scripts/",
16
+ "src/index.ts",
17
+ "src/commands/",
18
+ "src/lib/",
19
+ "src/services/",
20
+ "agent.config.template.json",
21
+ "package-lock.json",
22
+ "tsconfig.json"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
28
  "dev": "tsx watch src/index.ts",
29
29
  "cms-agent": "node ./bin/cms-agent.js",
30
30
  "sync-display": "node -e \"const{cpSync,rmSync,mkdirSync}=require('fs');rmSync('public',{recursive:true,force:true});mkdirSync('public',{recursive:true});cpSync('../display/dist','public',{recursive:true});console.log('Display synced to agent/public/')\"",
@@ -68,11 +68,24 @@ foreach ($tn in @($AgentTask, $KioskTask, $GuardianTask)) {
68
68
  if ($t) { Stop-ScheduledTask -TaskName $tn -ErrorAction SilentlyContinue; Unregister-ScheduledTask -TaskName $tn -Confirm:$false -ErrorAction SilentlyContinue }
69
69
  }
70
70
 
71
- # Kill processes
72
- Write-Host "[0c] Killing node.exe and Chrome..." -ForegroundColor Yellow
73
- Get-Process -Name "node" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
74
- Get-Process -Name "chrome" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
75
- Start-Sleep -Seconds 2
71
+ # Kill processes
72
+ Write-Host "[0c] Killing node.exe and Chrome..." -ForegroundColor Yellow
73
+ # IMPORTANT:
74
+ # If install-windows.ps1 is launched from the npm CLI wrapper (node.exe),
75
+ # killing all node.exe would terminate the installer mid-run.
76
+ $parentPid = $null
77
+ try {
78
+ $parentPid = (Get-CimInstance Win32_Process -Filter "ProcessId=$PID" -ErrorAction SilentlyContinue).ParentProcessId
79
+ } catch { }
80
+ Get-Process -Name "node" -ErrorAction SilentlyContinue | ForEach-Object {
81
+ if ($parentPid -and $_.Id -eq $parentPid) {
82
+ Write-Host " Keeping installer parent node.exe (PID $($_.Id))" -ForegroundColor DarkGray
83
+ } else {
84
+ Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
85
+ }
86
+ }
87
+ Get-Process -Name "chrome" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
88
+ Start-Sleep -Seconds 2
76
89
 
77
90
  # Remove old files (keep NSSM and logs)
78
91
  Write-Host "[0d] Removing old agent files..." -ForegroundColor Yellow