Skip to content

Disable agent service auto-restart (keep auto-start); log decorated startup version marker#63

Merged
denys-gif merged 3 commits into
masterfrom
hotfix/disable-service-auto-restart
Jul 10, 2026
Merged

Disable agent service auto-restart (keep auto-start); log decorated startup version marker#63
denys-gif merged 3 commits into
masterfrom
hotfix/disable-service-auto-restart

Conversation

@mikhailm-coder

@mikhailm-coder mikhailm-coder commented Jul 9, 2026

Copy link
Copy Markdown

Description

Two independent changes to the OpenFrame MeshAgent:

  1. Disable the installed agent service's auto-restart-on-crash, while keeping auto-start-on-boot. Previously the agent daemon was configured to respawn after any crash/exit on every platform (Windows SCM recovery actions, systemd Restart=on-failure, launchd KeepAlive, upstart/procd/OpenRC respawn). It now starts on boot but is not restarted if it exits or crashes.

  2. Log a decorated startup marker with the version on agent startup, so the line is parseable by openframe-client.

Improvements

  • Pass failureRestart: 0 in both daemon install option-builders in modules/agent-installer.js (macOS LaunchDaemon + Windows/Linux). The existing gating failureRestart == null || failureRestart > 0 already honors this on all ~8 platform paths (Windows FailureActions, systemd, upstart, procd, OpenRC, SysV, BSD rc, pseudo-daemon).
  • Make the macOS LaunchDaemon KeepAlive key honor failureRestart in modules/service-manager.js (it was hard-coded <true/>), matching every other platform.
  • Auto-start-on-boot is untouched: Windows start type 0x02, systemd WantedBy=multi-user.target + systemctl enable, and macOS RunAtLoad all remain.
  • Emit a decorated startup line in meshcore/agentcore.c (in MeshAgent_AgentMode, right after openframe file logging is enabled) via openframe_printf, printing both version markers found in the tree — the build/commit date (SOURCE_COMMIT_DATE, same string used in the HTTP User-Agent) and the integer self-update version (MESH_AGENT_VERSION):
    <ts> INFO MeshAgent starting (build <SOURCE_COMMIT_DATE>, self-update version <MESH_AGENT_VERSION>) tool_id=meshcentral-agent
    

Scope note

"Auto-restart disabled" is scoped to the agent daemon — the only persistent service a normal agent install creates. Two other installService call sites are intentionally left as-is: the transient macOS message-box helper (a throwaway LaunchAgent that already uses KeepAlive false) and meshcmd's own MicroLMS/MeshCommander service (a separate CLI tool, only installed via an explicit meshcmd ... install).

⚠️ Behavioral implication: disabling restart-on-exit also affects self-update, which relies on the agent exiting and the service manager relaunching the new binary (launchd KeepAlive, systemd Restart=). With restart off, an agent that exits to self-update — or simply crashes — will stay down until the next reboot.

Task

No linked ticket.

Summary by CodeRabbit

  • New Features

    • Added an OpenFrame-compatible startup marker when OpenFrame mode is enabled, including build and version details for client parsing.
  • Bug Fixes

    • Updated service installation behavior so auto-start services no longer restart automatically after a crash or exit, with consistent behavior across platforms.

mikhailm-coder and others added 2 commits July 9, 2026 13:53
…boot)

The installed agent service was set to respawn after a crash/exit on every
platform (Windows SCM recovery actions, systemd Restart=on-failure, launchd
KeepAlive, upstart/procd/OpenRC respawn). Disable that; keep start-on-boot.

- agent-installer.js: pass failureRestart: 0 in both daemon install option
  builders (macOS LaunchDaemon + Windows/Linux). The existing gating
  (failureRestart == null || > 0) already honors this on the ~8 gated paths.
- service-manager.js: make the macOS LaunchDaemon KeepAlive key honor
  failureRestart (was hard-coded <true/>), matching every other platform.

Auto-start is untouched: Windows start type 0x02, systemd WantedBy/enable,
and macOS RunAtLoad all remain in place.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
On openframe-mode startup, right after openframe file logging is enabled,
emit a decorated line via openframe_printf so openframe-client can parse it:

  <ts> INFO MeshAgent starting (build <SOURCE_COMMIT_DATE>, self-update version <MESH_AGENT_VERSION>) tool_id=meshcentral-agent

Prints both version markers found in the tree: the build/commit date (the
same string used in the HTTP User-Agent) and the integer self-update version.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f008969f-6910-4bf1-81d3-f5dfc12db4f4

📥 Commits

Reviewing files that changed from the base of the PR and between a85a117 and 7f69a69.

📒 Files selected for processing (3)
  • meshcore/agentcore.c
  • modules/agent-installer.js
  • modules/service-manager.js

📝 Walkthrough

Walkthrough

Adds an OpenFrame-decorated startup log marker in agentcore.c printed when --openframe-mode is enabled. In agent-installer.js, sets failureRestart:0 for AUTO_START services in both LaunchDaemon and legacy install paths; service-manager.js makes the launchd KeepAlive plist value conditional on this option instead of always true.

Changes

Startup Marker and Service Restart Behavior

Layer / File(s) Summary
OpenFrame startup marker
meshcore/agentcore.c
Emits an openframe_printf startup marker with build commit date and version when --openframe-mode is enabled.
AUTO_START failureRestart option and conditional KeepAlive
modules/agent-installer.js, modules/service-manager.js
Sets failureRestart:0 for AUTO_START services in createLaunchDaemon and legacy installService, and makes the launchd KeepAlive plist value conditional on options.failureRestart instead of hardcoded true.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AgentInstaller
  participant ServiceManager
  participant LaunchdPlist

  AgentInstaller->>ServiceManager: installService(options: {startType: AUTO_START, failureRestart: 0})
  ServiceManager->>ServiceManager: keepAlive = failureRestart null or >0 ? true : false
  ServiceManager->>LaunchdPlist: write KeepAlive = keepAlive
Loading

Suggested reviewers: denys-gif

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both main changes: disabling agent service auto-restart while keeping auto-start, and adding a decorated startup version marker.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/disable-service-auto-restart

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@denys-gif denys-gif merged commit 7f2ad09 into master Jul 10, 2026
4 checks passed
@denys-gif denys-gif deleted the hotfix/disable-service-auto-restart branch July 10, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants