Start, stop and update the daemon
Result: the worker daemon runs, comes back at login, and runs the Simlock version you want.
The daemon is the background process that owns this machine’s devices and leases. Every simlock command talks to it. The first command that needs it starts it and waits up to 20 seconds for it to answer. You manage it by hand only to apply a config change, to start it at login, or to update Simlock.
Start, stop and restart
Section titled “Start, stop and restart”simlock daemon startDaemon runningConsole: http://127.0.0.1:4701/The Console: line appears only when HTTP is on. If the daemon already runs, the command changes nothing and prints the same lines.
simlock daemon stopDaemon stoppingWith no daemon running, stop prints Daemon not running and exits 0. It never starts a daemon.
- Stopping ends no lease. It shuts down every device that has no lease. Leased devices keep running, and the next daemon picks them up.
stopreturns once the daemon has exited. The daemon first finishes the work it started. After 300 seconds the command gives up withSERVICE_FAILED. Commands sent in the meantime fail withDAEMON_STOPPING.
To restart, for example after simlock config set:
simlock daemon stopsimlock daemon startCheck: simlock daemon status prints Daemon: running (worker).
Start it at login
Section titled “Start it at login”Without a service, the daemon keeps running after you close the terminal, but it does not come back after a reboot.
-
Install the service:
Terminal window simlock daemon installService installed: com.callstack.simlock.worker (launchd)Daemon runningTo start after a reboot, turn on automatic login for this user. -
Turn on automatic login for this user in System Settings > Users & Groups. The service runs only while this user is logged in at the screen.
The service is a LaunchAgent at ~/Library/LaunchAgents/com.callstack.simlock.worker.plist.
-
Install the service:
Terminal window simlock daemon installService installed: com.callstack.simlock.worker (systemd)Daemon runningTo start after a reboot without logging in, run: loginctl enable-linger dana -
Turn on linger, so the daemon keeps running when you log out and starts after a reboot:
Terminal window loginctl enable-linger danaWithout linger, logging out of your last session stops the daemon and its emulators. Simlock does not turn linger on for you.
The service is a systemd user unit at ~/.config/systemd/user/com.callstack.simlock.worker.service (under $XDG_CONFIG_HOME when you set it).
With no login session and no linger, for example over SSH, daemon install fails with SERVICE_FAILED (Failed to connect to bus) and installs nothing. Log in, or turn on linger, and run it again.
-
Install the service:
Terminal window simlock daemon installService installed: com.callstack.simlock.worker (task-scheduler)Daemon runningTo start after a reboot, turn on automatic login for this user. -
Turn on automatic login for this user. The service is a Task Scheduler task that starts at logon, and runs only while this user is logged in at the screen.
- If nobody is logged in at the screen,
daemon installstill succeeds, starts the daemon without the service and says so. That daemon stops when the SSH session ends. - With the service installed and the user logged in at the screen, a command over SSH starts the daemon in the desktop session, and it outlives the SSH session.
- Ending the task in Task Scheduler does not stop the daemon. Use
simlock daemon stop. - The task runs a small Simlock program with no window that starts the daemon again after a failure.
daemon.loghas a line for each restart.
On every system:
- The service starts the daemon again 10 seconds after it crashes.
- If a daemon already ran,
installstops it first and printsStopped the running daemon; leases are kept. - A config file the CLI refuses stops
installwith exit 2 before anything changes. - The service saves
SIMLOCK_HOME,PATH,JAVA_HOME,DEVELOPER_DIRand the Android SDK variables (such asANDROID_HOME) as they are when you runinstall. Runsimlock daemon installagain after you change one of them, or after you move or upgrade Node or Simlock (for example with nvm or Homebrew). simlock daemon stopstill stops the daemon. The service leaves it stopped until the next command starts it.- With a
SIMLOCK_HOMEother than the default folder, the service name gets a short suffix, such ascom.callstack.simlock.worker.3f9c2a.
Check: the last line of simlock daemon status reads Service: installed (launchd, com.callstack.simlock.worker) (systemd or task-scheduler on the other systems).
To remove the service and stop the daemon:
simlock daemon uninstallDaemon stoppingService removed: com.callstack.simlock.worker (launchd)Check whether it runs
Section titled “Check whether it runs”simlock daemon statusIt never starts the daemon. It prints Daemon stopped, or the same report as simlock status (see See what the worker is doing), then one line about the service:
| Line | Meaning | Fix |
|---|---|---|
Service: not installed |
You have not run simlock daemon install. |
Install it if you want the daemon at login. |
Service: installed (launchd, com.callstack.simlock.worker) |
The service is set up and works. | Nothing. |
Service: not loaded (...): commands start the daemon without it |
Nobody is logged in at the screen, there is no Linux user session, or the Windows task is disabled. | Log in at the screen, or turn on linger on Linux. |
Service: broken (...): <path> is gone; run simlock daemon install |
The Node or Simlock the service starts has moved, for example after an nvm or Homebrew upgrade. | Run simlock daemon install again. |
Daemon: starting means the daemon still reads the machine’s devices. Devices, leases and capacity appear once it finishes.
When the service cannot run, commands still work: they start the daemon without it and say so:
Service com.callstack.simlock.worker is not loaded; started the daemon without it.Add --json for a machine-readable answer, such as {"status":"stopped"}.
Where files live
Section titled “Where files live”Everything is in ~/.simlock, or the folder SIMLOCK_HOME names.
Everything is in ~/.simlock, or the folder SIMLOCK_HOME names.
Everything is in %USERPROFILE%\.simlock, or the folder SIMLOCK_HOME names:
$env:SIMLOCK_HOME = "D:\simlock"| File | What it holds |
|---|---|
config.json |
Your settings. See Change a setting. |
state.db |
Devices, leases, enrolled phones, what the warm pool learned, and HTTP tokens. |
history.db |
The event history and usage figures behind simlock events and simlock stats. |
daemon.log, daemon.log.1 |
The daemon’s log, and one older file. |
daemon.sock |
The socket the CLI and agents connect to. Windows has no file: the daemon listens on a named pipe. |
admin.token |
The secret the CLI uses to connect as an admin. |
devices/ios, devices/android |
The simulators and emulators Simlock made. These take the most space. |
Anyone who can open the data folder can lease devices, so Simlock creates it readable by your user only. It does not change a folder that already exists. If other users can open it, the daemon log says so at each start, with the command that fixes it:
chmod 700 on the folder.
chmod 700 on the folder.
An icacls command with your folder and your account’s security identifier:
data directory D:\simlock is accessible to other users (BUILTIN\Users); run icacls "D:\simlock" /inheritance:r /grant:r "*S-1-5-21-...:(OI)(CI)F" "*S-1-5-18:(OI)(CI)F" "*S-1-5-32-544:(OI)(CI)F"- One worker per user. A second worker started from another
SIMLOCK_HOMErefuses to start withanother Simlock worker runs for this user, and prints the command that stops the first one. - A gateway on the same machine keeps its own files in
~/.simlock/gatewayand runs its own daemon. Add--gatewayto reach it, for examplesimlock --gateway daemon status.
Read the log
Section titled “Read the log”simlock daemon logs # the last 100 linessimlock daemon logs --follow # then each new line, until Ctrl-CThe log’s format and how to make it more detailed: See what the worker is doing.
What a restart keeps
Section titled “What a restart keeps”After a daemon stop, a crash or a reboot, the new daemon checks its records against the devices that really exist:
| What | After a restart |
|---|---|
| Idle devices | Shut down by daemon stop or an update; left as they were by a crash or reboot. They boot again when a lease or the warm pool needs them. |
| A lease whose device still runs | Kept. Its agent goes on renewing it. If its time ran out while no daemon ran, it expires at start. |
| A lease whose device stopped, as after a reboot | Ends with reason device-lost, or as expired if its time had run out. |
| A lease on a physical device | Kept. It ends as usual: when its time runs out or the device is unplugged. |
| A request still waiting in the queue | Fails with INTERNAL: The daemon restarted before this lease request settled; send it again with a new key. The agent asks again. |
Update Simlock
Section titled “Update Simlock”-
Run the update:
Terminal window simlock updateUpdating simlock 0.6.2 → 0.7.0Waiting for 2 leases to end. Ctrl-C stops following; simlock update --force stops waiting.Installing [email protected]Restarting the daemonsimlock 0.7.0 is runningIt installs the newest Simlock and restarts the daemon once the current leases have ended. While it waits, the daemon takes no new leases: new and queued requests fail with
DAEMON_UPDATING. Held leases renew and release as usual, andsimlock statusshowsUpdating to 0.7.0: waiting for 2 leases. -
To stop waiting, run
simlock update --force, from this shell or another one. Leases on running devices survive the restart.
Check: simlock status shows Simlock: 0.7.0.
--version 0.7.0 installs that exact version, older ones included. Admins can also update over HTTP with POST /v1/update. To update workers behind a gateway, see Maintain workers.
| What you see | Cause | Fix |
|---|---|---|
simlock status shows Last update failed (installing): <npm's message> |
The install failed, for example npm cannot write its global folder. The old daemon runs and takes leases again. | Fix what npm names, then update again. |
Last update failed (restarting): … |
The new version did not start within two minutes. Simlock put the old version back and started it. | Read simlock daemon logs. |
UPDATE_UNSUPPORTED_INSTALL |
Simlock was not installed with npm i -g simlock, for example a source checkout or a pnpm global install. Nothing changed. |
Upgrade by hand. |
UPDATE_SHARED_INSTALL |
A worker and a gateway of the same user share one install, and the other one runs. | Stop it, update, then start it again. |
PROTOCOL_VERSION_UNSUPPORTED |
The running daemon is too old to update itself. | Upgrade by hand. |
Upgrade by hand
Section titled “Upgrade by hand”-
Stop the daemon. This works even when the daemon is another version and refuses other commands with
PROTOCOL_VERSION_UNSUPPORTED.Terminal window simlock daemon stop -
Install the new version:
Terminal window npm i -g simlock -
Start the daemon and check the machine:
Terminal window simlock daemon startsimlock doctor
Check: simlock doctor prints no Missing line, and simlock status shows the new version. Leases on running devices survive the upgrade. If the daemon runs as a service, run simlock daemon install again when the Node or Simlock path changed.
From a version that used state.json
Section titled “From a version that used state.json”Older versions kept their state in ~/.simlock/state.json and HTTP tokens in ~/.simlock/tokens.json. This version does not read them, and refuses to start while either file exists:
{"error":{"code":"DAEMON_STARTUP_FAILED","message":"The daemon could not start: Found /Users/dana/.simlock/state.json, which this Simlock no longer reads. To upgrade: with the older Simlock, release every lease and run `simlock nuke --delete-devices`; then remove /Users/dana/.simlock/state.json and start again. ..."}}Nothing carries over, so clear the old version’s devices first.
-
With the older Simlock installed, release every lease and delete its devices. Answer
ywhen asked. If you already installed the new version, put the old one back for this step, for example withnpm i -g [email protected].Terminal window simlock release --allsimlock nuke --delete-devicessimlock daemon stop -
Remove the old files:
Terminal window rm ~/.simlock/state.json ~/.simlock/tokens.json -
Install the new version and start it:
Terminal window npm i -g simlocksimlock daemon start -
If agents reached this worker over HTTP, their tokens are gone. Make new ones with
simlock token create --role agent. See Give agents and people access.
Check: simlock daemon status prints Daemon: running (worker).
On a gateway, remove the files the message names in ~/.simlock/gateway, then make each worker’s join token again and set it on that worker. See Add a worker.
When it fails
Section titled “When it fails”| Error | Exit | Cause | Fix |
|---|---|---|---|
DAEMON_STARTUP_FAILED |
1 | The daemon did not come up. The message says why. | See The daemon will not start. |
USAGE |
2 | config.json has a wrong value. The CLI checks it before it starts the daemon, and the message names the key. |
Fix the key. See Change a setting. |
SERVICE_FAILED |
1 | launchctl, systemctl or schtasks failed or took longer than 10 seconds, or the old daemon did not stop within 300 seconds. The message names the command and its first error line. |
Fix what the message names and run the command again. A failed load removes the service file. |
DAEMON_STOPPING |
1 | The daemon is shutting down. | Wait a moment and run the command again. |
Flags: CLI reference, simlock update.