Deployment
Keep the agent running across reboots, upgrade it, and publish new versions.
A watch-mode agent started by hand stops when its window closes or the host reboots. On a host that should sync unattended, put it under a supervisor that starts it at boot and restarts it if it exits.
Whatever runs it, two things hold:
- It runs from the application root. The agent reads
.envfrom the directory it runs in, so that is the host application's.env, not one insync-agent/. - Each application gets its own process, named after it, so its logs and restarts stay separate from the other schools on the host.
Pick a build
| Host | Download | Runs with |
|---|---|---|
| Windows 10 1809+, Server 2019+ | sync-agent-windows-x64.exe | Nothing else |
| Linux x64 | sync-agent-linux-x64 | Nothing else |
| Anything older, e.g. Windows Server 2016 | sync-agent-node.mjs | Node.js 22 or later |
On a host too old for the binaries, the .exe stops at once with The procedure entry point GetThreadDescription could not be located. The Node.js build behaves the same, flags
included, and needs nothing installed beside it.
Laragon's Node.js
Laragon ships its own, often old, Node.js and puts it first on the path in its terminal.
Install Node.js 22+ system-wide and refer to it by full path,
C:\Program Files\nodejs\node.exe, so the agent never picks up Laragon's.
pm2
pm2 works the same on Windows and Linux. Put an
ecosystem.config.cjs next to the agent:
pac_local/
├── .env
└── sync-agent/
├── sync-agent-windows-x64.exe (or sync-agent-linux-x64)
└── ecosystem.config.cjsconst path = require("path");
const root = path.join(__dirname, "..");
const binary = process.platform === "win32" ? "sync-agent-windows-x64.exe" : "sync-agent-linux-x64";
module.exports = {
apps: [
{
name: `sync-agent-${path.basename(root)}`,
script: path.join(__dirname, binary),
args: "--watch --plain",
interpreter: "none",
cwd: root,
watch: false,
autorestart: true,
kill_timeout: 60000,
},
],
};For the Node.js build, point script at sync-agent-node.mjs and set interpreter to Node
instead, by full path where Laragon is installed:
script: path.join(__dirname, "sync-agent-node.mjs"),
interpreter: "C:\\Program Files\\nodejs\\node.exe",On Linux, make the binary executable, then start it from the sync-agent folder:
chmod +x sync-agent/sync-agent-linux-x64
cd sync-agent
pm2 start ecosystem.config.cjs
pm2 saveinterpreter: "none"runs the binary directly; without it pm2 hands the file to Node.cwdis the application root, where.envis.argsare the agent's flags. pm2's ownwatchrestarts on file changes and stays off.--plainwrites one timestamped line per cycle, which reads better inpm2 logs.kill_timeoutlets a cycle in progress finish when pm2 stops the agent..cjs, because a Laravelpackage.jsonusually declares"type": "module", which makes Node rejectmodule.exportsin a.jsfile.
With several applications on one host, copy the same file into each one's sync-agent/ and
start each. Check on them with pm2 status and pm2 logs sync-agent-pac_local.
To start on boot on Linux, run pm2 startup, run the sudo command it prints, then
pm2 save. On Windows pm2 startup is not supported; use Task Scheduler below, or
pm2-installer.
Windows Task Scheduler
Built into Windows, with nothing to install. The one-command installer does
every step below for you; these are the same steps by hand. Run them all in PowerShell as
Administrator, from the application's folder. The examples use C:\laragon\www\pac_local.
Not as SYSTEM
Older versions of this page registered the task as SYSTEM. Under Laragon's www, every
signed-in user can usually change the application's files, so anyone could edit start.bat and
have Windows run their own commands as SYSTEM. The steps below lock the folder and run the
agent as LOCAL SERVICE, a low-privilege account. A task set up the old way can be fixed in
place: see Securing an existing task.
1. Lock the agent's folder
Before anything goes in it, give sync-agent\ to Administrators and drop every other
permission, so only Administrators and SYSTEM can change it and everyone else can only read and
run it. Accounts are given by SID, which works on a Windows in any language:
New-Item -ItemType Directory -Force sync-agent | Out-Null
icacls sync-agent /setowner "*S-1-5-32-544" /T /C /Q
icacls sync-agent /reset /T /C /Q
icacls sync-agent /inheritance:r /grant:r "*S-1-5-32-544:(OI)(CI)F" "*S-1-5-18:(OI)(CI)F" "*S-1-5-32-545:(OI)(CI)RX" "*S-1-5-19:(OI)(CI)RX" /C /QThe SIDs are Administrators (S-1-5-32-544), SYSTEM (S-1-5-18), Users (S-1-5-32-545) and
LOCAL SERVICE (S-1-5-19). Copy the agent into the folder after this. From now on, changing
anything in it takes Administrator, Notepad included.
2. Write start.bat
Written from PowerShell, which also avoids Notepad saving it as start.bat.txt. Use full paths:
they work whatever folder it runs from.
@'
@echo off
cd /d "C:\laragon\www\pac_local"
:loop
"C:\Program Files\nodejs\node.exe" "C:\laragon\www\pac_local\sync-agent\sync-agent-node.mjs" --watch --plain >> "C:\laragon\www\pac_local\sync-agent\agent.log" 2>&1
ping -n 31 127.0.0.1 >nul
goto loop
'@ | Set-Content sync-agent\start.bat -Encoding AsciiFor a binary, run "C:\laragon\www\pac_local\sync-agent\sync-agent-windows-x64.exe" --watch --plain
on that line instead. The loop restarts the agent 30 seconds after it exits, and its output goes
to agent.log, since there is no window to show it. The cd matters: the agent reads .env
from the folder it runs in.
3. Let the agent write its log
LOCAL SERVICE can only read the folder, so create the log and let it change that one file:
New-Item -ItemType File -Force sync-agent\agent.log | Out-Null
icacls sync-agent\agent.log /grant "*S-1-5-19:M"4. Register the task
At startup, as LOCAL SERVICE:
$action = New-ScheduledTaskAction -Execute "C:\laragon\www\pac_local\sync-agent\start.bat"
$trigger = New-ScheduledTaskTrigger -AtStartup
$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
$account = (New-Object System.Security.Principal.SecurityIdentifier 'S-1-5-19').Translate([System.Security.Principal.NTAccount]).Value
$principal = New-ScheduledTaskPrincipal -UserId $account -LogonType ServiceAccount -RunLevel Limited
Register-ScheduledTask -TaskName "sync-agent-pac_local" -Action $action -Trigger $trigger -Settings $settings -Principal $principal-ExecutionTimeLimit (New-TimeSpan) matters: without it, Task Scheduler stops the agent
after three days. The account is looked up by SID because its name depends on the language.
Start it without rebooting, and follow the log:
Start-ScheduledTask -TaskName "sync-agent-pac_local"
Get-Content C:\laragon\www\pac_local\sync-agent\agent.log -Wait -Encoding UTF8If the log says Missing required environment variable, LOCAL SERVICE cannot read the
application's .env. Let it read that one file, then restart the task:
icacls .env /grant "*S-1-5-19:R"Watching the log
The task runs in the background, with no window and no one logged in. To watch its log whenever
you do log in, save a logs.bat beside start.bat:
@'
@echo off
title Sync agent - pac_local
powershell -NoExit -Command "Get-Content 'C:\laragon\www\pac_local\sync-agent\agent.log' -Tail 50 -Wait -Encoding UTF8"
'@ | Set-Content sync-agent\logs.bat -Encoding AsciiThen press Win + R, open shell:startup, and paste a shortcut to logs.bat there. The
window opens at each login with the last 50 lines and follows new cycles. Closing it stops
only the window, not the agent. It shows one line per cycle but no countdown, which the agent
draws only in a terminal it runs in.
Stopping it
Stop-ScheduledTask ends start.bat but can leave the agent running. Find it by its command
line, and stop it by id:
Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -like '*sync-agent*' } | Format-List ProcessId, Name, CommandLine
Stop-Process -Id <ProcessId>Securing an existing task
For a task registered as SYSTEM by an older version of this page. Find its name in Task
Scheduler, or with:
Get-ScheduledTask | Where-Object { "$($_.Actions.Execute) $($_.Actions.Arguments)" -like '*sync-agent*' } | Format-List TaskPath, TaskName, State, @{ n = 'User'; e = { $_.Principal.UserId } }Then, from the application's folder, lock the folder and let the agent write its log (steps 1 and
3 above, without creating anything), switch the task to LOCAL SERVICE, and restart it. Replace
sync-agent-pac_local with the task's name:
icacls sync-agent /setowner "*S-1-5-32-544" /T /C /Q
icacls sync-agent /reset /T /C /Q
icacls sync-agent /inheritance:r /grant:r "*S-1-5-32-544:(OI)(CI)F" "*S-1-5-18:(OI)(CI)F" "*S-1-5-32-545:(OI)(CI)RX" "*S-1-5-19:(OI)(CI)RX" /C /Q
icacls sync-agent\agent.log /grant "*S-1-5-19:M"
$account = (New-Object System.Security.Principal.SecurityIdentifier 'S-1-5-19').Translate([System.Security.Principal.NTAccount]).Value
$principal = New-ScheduledTaskPrincipal -UserId $account -LogonType ServiceAccount -RunLevel Limited
Set-ScheduledTask -TaskName "sync-agent-pac_local" -Principal $principal
Stop-ScheduledTask -TaskName "sync-agent-pac_local"
Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -like '*sync-agent*' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force }
Start-ScheduledTask -TaskName "sync-agent-pac_local"The restart matters: the agent that is already running keeps running as SYSTEM until it stops.
Afterwards, check the log for new cycles, and the .env note under step 4 if it shows
Missing required environment variable. Both Stop-Process lines end every agent on the machine
whose command line mentions sync-agent; on a host with more than one application's agent, stop
only this one's by its id instead.
MySQL has to start at boot too
Laragon starts MySQL when someone opens it after logging in, not at boot. Until MySQL is up every cycle fails and retries, so the agent recovers once it starts — but if nobody logs in, it never does. Run MySQL as a Windows service on a host that must sync unattended.
Upgrading
Downloads keep the same file name across versions, so no config, task or script changes.
- Linux binary: copy the new file over the old one,
chmod +xit, and restart. - Windows binary: stop the agent first. Windows will not overwrite a running
.exe. - Node.js build: replace the file and restart. Node holds no lock on it.
The school's Overview shows the version each agent reports, so you can confirm it took.
Publishing a release
The dashboard's Download agent offers whatever pnpm release built into
apps/agent/release. Bump version in apps/agent/package.json first, then:
pnpm release # release/sync-agent-<version>-windows-x64.exe, -linux-x64, -node.mjs, manifest.jsonIt builds every target with Bun — cross-compiling works from either
platform — names them with the version, and writes a manifest with each file's size and
checksum. The binaries are around 110 MB because they carry the runtime; the Node.js build is
about 1 MB, with mysql2 bundled in.
The server reads apps/agent/release unless AGENT_DOWNLOADS_DIR points elsewhere. Under
Docker Compose the folder is mounted from the host, read-only, and kept out of the image, so
docker compose up --build does not build it. Where the server has no pnpm or Bun, build on
your own machine and upload the whole folder, manifest included:
scp -r apps/agent/release user@server:/path/to/sync-monitoring/apps/agent/- Only the matching version is offered. The server treats the agent version it was built with as the latest, so after a version bump, rebuild the server too.
- A half-copied file is never offered. Each file must be present at the size the manifest recorded. Replace the folder whole rather than mixing files from two releases.
- Nothing restarts. The server reads the folder each time the dialog opens.
Agents before 1.0.0 report no version
They show as older than 1.0.0. They also lack Retry now in the Overview tab's Queue section and the capture trigger check, and the dashboard says so where those would appear.