Skip to content

Running with launchd

Running the agent as a launchd service ensures it starts automatically on login and restarts if it crashes.

  • macOS system
  • EpochProxy agent installed to /usr/local/bin/epoch-agent
  • Agent already activated (has valid state file)

Create a plist file in your LaunchAgents folder:

Terminal window
nano ~/Library/LaunchAgents/cloud.epochproxy.agent.plist

Paste the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>cloud.epochproxy.agent</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/epoch-agent</string>
<string>--state-file</string>
<string>/Users/YOUR_USERNAME/.config/epoch-agent/state.json</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/Users/YOUR_USERNAME/.config/epoch-agent/stdout.log</string>
<key>StandardErrorPath</key>
<string>/Users/YOUR_USERNAME/.config/epoch-agent/stderr.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin</string>
</dict>
</dict>
</plist>

Important: Replace YOUR_USERNAME with your actual username.

Terminal window
mkdir -p ~/.config/epoch-agent

If you haven’t activated the agent yet:

Terminal window
epoch-agent --activation-code YOUR_CODE

Press Ctrl+C after you see “Agent is ready”.

Terminal window
launchctl load ~/Library/LaunchAgents/cloud.epochproxy.agent.plist
Terminal window
launchctl list | grep epochproxy

You should see cloud.epochproxy.agent with a PID.

Terminal window
launchctl list | grep epochproxy

A running service shows a PID number. A stopped service shows -.

Terminal window
launchctl start cloud.epochproxy.agent
Terminal window
launchctl stop cloud.epochproxy.agent
Terminal window
launchctl unload ~/Library/LaunchAgents/cloud.epochproxy.agent.plist
Terminal window
launchctl unload ~/Library/LaunchAgents/cloud.epochproxy.agent.plist
launchctl load ~/Library/LaunchAgents/cloud.epochproxy.agent.plist
Terminal window
tail -f ~/.config/epoch-agent/stdout.log
Terminal window
tail -f ~/.config/epoch-agent/stderr.log
Terminal window
tail -f ~/.config/epoch-agent/*.log

To run the agent for all users (requires admin privileges):

Terminal window
sudo nano /Library/LaunchDaemons/cloud.epochproxy.agent.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>cloud.epochproxy.agent</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/epoch-agent</string>
<string>--state-file</string>
<string>/var/lib/epoch-agent/state.json</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/var/log/epoch-agent.log</string>
<key>StandardErrorPath</key>
<string>/var/log/epoch-agent.error.log</string>
</dict>
</plist>
Terminal window
sudo mkdir -p /var/lib/epoch-agent
Terminal window
sudo launchctl load /Library/LaunchDaemons/cloud.epochproxy.agent.plist

Check the error log:

Terminal window
cat ~/.config/epoch-agent/stderr.log

The binary may be quarantined. Remove the quarantine attribute:

Terminal window
xattr -d com.apple.quarantine /usr/local/bin/epoch-agent

Check for:

  1. Valid state file exists
  2. Network connectivity
  3. Correct file paths in the plist

Verify the agent binary location:

Terminal window
which epoch-agent

Update the plist if the path is different.