FlowFuse / device-agent

An agent to run FlowFuse managed instances of Node-RED on devices
Apache License 2.0
15 stars 8 forks source link

Quitting device agent after failed node-red start is not possible #251

Closed Steve-Mcl closed 3 months ago

Steve-Mcl commented 3 months ago

Current Behavior

When a node-red start up issue occurs (restart loop), exiting via CTRL-C did not quit the agent.

C:\Users\Stephen>flowfuse-device-agent
[AGENT] 12/04/2024 11:21:12 [info] FlowFuse Device Agent
[AGENT] 12/04/2024 11:21:12 [info] ----------------------
[AGENT] 12/04/2024 11:21:12 [info] Agent starting...
[AGENT] 12/04/2024 11:21:12 [info] Version: 2.3.1
[AGENT] 12/04/2024 11:21:12 [info] Mode: Device Mode
[AGENT] 12/04/2024 11:21:12 [info] Device: LlxGYqVarE
[AGENT] 12/04/2024 11:21:12 [info] ForgeURL: https://forge.flowfuse.dev
[AGENT] 12/04/2024 11:21:12 [info] Starting MQTT heartbeat thread. Interval: 30s (±5s)
[AGENT] 12/04/2024 11:21:12 [info] MQTT connected
[AGENT] 12/04/2024 11:21:12 [info] License enabled
[AGENT] 12/04/2024 11:21:12 [info] Enabling developer mode
[AGENT] 12/04/2024 11:21:12 [info] Developer Mode: no flows found - updating to latest snapshot
[AGENT] 12/04/2024 11:21:13 [info] Launching with new settings...
[AGENT] 12/04/2024 11:21:13 [info] Configuration :-
[AGENT] 12/04/2024 11:21:13 [info]   * Application        : g17Pk5LmEk
[AGENT] 12/04/2024 11:21:13 [info]   * Snapshot           : none
[AGENT] 12/04/2024 11:21:13 [info]   * Settings           : 293a4dd6cd619dd0b2dc80470c25b5157f7edf3180405fdde43199c1669ced91
[AGENT] 12/04/2024 11:21:13 [info]   * Operation Mode     : developer
[AGENT] 12/04/2024 11:21:13 [info]   * Target State       : running
[AGENT] 12/04/2024 11:21:13 [info]   * Licensed           : yes
[AGENT] 12/04/2024 11:21:13 [info] Environment :-
[AGENT] 12/04/2024 11:21:13 [info]   * FF_DEVICE_ID       : LlxGYqVarE
[AGENT] 12/04/2024 11:21:13 [info]   * FF_DEVICE_NAME     : Device 1
[AGENT] 12/04/2024 11:21:13 [info]   * FF_DEVICE_TYPE     : Latest Agent 1.12-git
[AGENT] 12/04/2024 11:21:13 [info]   * FF_APPLICATION_ID  : g17Pk5LmEk
[AGENT] 12/04/2024 11:21:13 [info]   * FF_APPLICATION_NAME: Grey's Test area
[AGENT] 12/04/2024 11:21:13 [info]   * FF_SNAPSHOT_ID     : LoWNR74Pl0
[AGENT] 12/04/2024 11:21:13 [info]   * FF_SNAPSHOT_NAME   : with project nodes
[AGENT] 12/04/2024 11:21:13 [info] Updating configuration files
[AGENT] 12/04/2024 11:21:13 [info] Installing dependencies
[AGENT] 12/04/2024 11:21:37 [info] Updating theme files
[AGENT] 12/04/2024 11:21:37 [info] Starting Node-RED
[NR] 12/04/2024 11:21:38 [info]

Welcome to Node-RED
===================

[NR] 12/04/2024 11:21:38 [info] Node-RED version: v3.1.7
[NR] 12/04/2024 11:21:38 [info] Node.js  version: v18.20.2
[NR] 12/04/2024 11:21:38 [info] Windows_NT 10.0.22631 x64 LE
[NR] 12/04/2024 11:21:38 [error] Failed to start server:
[NR] 12/04/2024 11:21:38 [error] Error: spawn EINVAL
    at ChildProcess.spawn (node:internal/child_process:414:11)
    at spawn (node:child_process:761:9)
    at Object.execFile (node:child_process:351:17)
    at C:\opt\flowfuse-device\project\node_modules\@node-red\registry\lib\installer.js:581:27
    at new Promise (<anonymous>)
    at Object.checkPrereq (C:\opt\flowfuse-device\project\node_modules\@node-red\registry\lib\installer.js:580:16)
    at Object.load (C:\opt\flowfuse-device\project\node_modules\@node-red\registry\lib\index.js:59:22)
    at C:\opt\flowfuse-device\project\node_modules\@node-red\runtime\lib\index.js:162:29
[AGENT] 12/04/2024 11:21:38 [info] Node-RED stopped unexpectedly - restarting
[AGENT] 12/04/2024 11:21:38 [info] Starting Node-RED
[NR] 12/04/2024 11:21:39 [info]

<< SNIP FOR BREVETY >>

Welcome to Node-RED
===================

[NR] 12/04/2024 11:21:41 [info] Node-RED version: v3.1.7
[NR] 12/04/2024 11:21:41 [info] Node.js  version: v18.20.2
[NR] 12/04/2024 11:21:41 [info] Windows_NT 10.0.22631 x64 LE
[NR] 12/04/2024 11:21:41 [error] Failed to start server:
[NR] 12/04/2024 11:21:41 [error] Error: spawn EINVAL
    at ChildProcess.spawn (node:internal/child_process:414:11)
    at spawn (node:child_process:761:9)
    at Object.execFile (node:child_process:351:17)
    at C:\opt\flowfuse-device\project\node_modules\@node-red\registry\lib\installer.js:581:27
    at new Promise (<anonymous>)
    at Object.checkPrereq (C:\opt\flowfuse-device\project\node_modules\@node-red\registry\lib\installer.js:580:16)
    at Object.load (C:\opt\flowfuse-device\project\node_modules\@node-red\registry\lib\index.js:59:22)
    at C:\opt\flowfuse-device\project\node_modules\@node-red\runtime\lib\index.js:162:29
[AGENT] 12/04/2024 11:21:41 [info] Node-RED restart loop detected - stopping
[AGENT] 12/04/2024 11:24:22 [info] Stopping Node-RED. Reason: shutdown
[AGENT] 12/04/2024 11:24:22 [info] Stopping Node-RED. Reason: shutdown
[AGENT] 12/04/2024 11:24:32 [system] Node-RED stop timed-out. Sending SIGKILL
Node-RED stop timed-out. Sending SIGKILL

Line [AGENT] 12/04/2024 11:24:22 [info] Stopping Node-RED. Reason: shutdown is in response to a CTRL-C in the console

Expected Behavior

Should quit on CTRL-C signal

Steps To Reproduce

On windows, cause node-red to fail to start, operate CTRL-C

Environment

joepavitt commented 2 months ago

@Steve-Mcl can we mark this as "Done" now?

Steve-Mcl commented 2 months ago

yeah, been out in the wild for a couple of weeks & has been thoroughly tested on win + *nix by Ben.