This guide explains how to install, configure, and manage the PrivaseeAI Security background service using macOS launchd.
The com.privaseeai.security.plist file configures PrivaseeAI Security to run as a persistent background service that:
- ✅ Runs
python -m privaseeai_security.orchestratorautomatically - ✅ Starts on boot (user agent)
- ✅ Auto-restarts if crashed (with a minimum restart delay enforced by ThrottleInterval)
- ✅ Logs to
/var/log/privaseeai/security.log - ✅ Runs from
/opt/privaseeaiworking directory - ✅ Executes as the current user
- ✅ Prevents rapid restart loops with a fixed 60-second ThrottleInterval between restarts
- Python 3.11+ - Ensure a Python 3.11+ interpreter is available in your PATH (via Homebrew, venv, or system Python)
- PrivaseeAI Security installed as a Python package
- Proper permissions to write to
/var/log/privaseeai/
First, ensure the package is installed in your Python environment:
# From the repository root
pip install -e .
# Verify installation
python3 -m privaseeai_security --versionCreate the log directory with proper permissions:
# Create log directory
sudo mkdir -p /var/log/privaseeai
# Set ownership to current user
sudo chown $(whoami):staff /var/log/privaseeai
# Restrict permissions so only this user can access logs
chmod 700 /var/log/privaseeaiCreate and configure the working directory:
# Create working directory
sudo mkdir -p /opt/privaseeai
# Set ownership to current user
sudo chown $(whoami):staff /opt/privaseeai
# Copy or link your configuration files
# (Optional - adjust based on your setup)
# cp config.yaml /opt/privaseeai/If you need Telegram alerts, set environment variables in the plist or create a configuration file:
# Option 1: Edit the plist file to add your tokens
# Edit com.privaseeai.security.plist and add to EnvironmentVariables:
# <key>TELEGRAM_BOT_TOKEN</key>
# <string>your_bot_token_here</string>
# <key>TELEGRAM_CHAT_ID</key>
# <string>your_chat_id_here</string>
# Option 2: Use a .env file in /opt/privaseeai/
cat > /opt/privaseeai/.env << 'EOF'
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT_ID=your_chat_id_here
EOF
chmod 600 /opt/privaseeai/.envCopy the plist file to the user's LaunchAgents directory:
# Copy plist to LaunchAgents
cp com.privaseeai.security.plist ~/Library/LaunchAgents/
# Verify the file is in place
ls -l ~/Library/LaunchAgents/com.privaseeai.security.plistStart the service immediately and enable auto-start on boot:
# Load and start the service
launchctl load ~/Library/LaunchAgents/com.privaseeai.security.plist
# Alternative: Bootstrap (recommended on macOS 11+)
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.privaseeai.security.plistVerify the service is running:
# List loaded services and check if ours is running
launchctl list | grep com.privaseeai.security
# Get detailed status
launchctl print gui/$(id -u)/com.privaseeai.securityExpected output for running service:
12345 0 com.privaseeai.security
(PID, exit code, label)
Monitor the service logs in real-time:
# Tail the log file
tail -f /var/log/privaseeai/security.log
# View last 100 lines
tail -n 100 /var/log/privaseeai/security.log
# Search for errors
grep -i error /var/log/privaseeai/security.logIf you need to restart the service:
# Stop the service
launchctl stop com.privaseeai.security
# Start the service (it will auto-restart due to KeepAlive)
launchctl start com.privaseeai.security
# Or unload and reload
launchctl unload ~/Library/LaunchAgents/com.privaseeai.security.plist
launchctl load ~/Library/LaunchAgents/com.privaseeai.security.plistTo completely stop and disable the service:
# Unload the service (stops it and disables auto-start)
launchctl unload ~/Library/LaunchAgents/com.privaseeai.security.plist
# Alternative: Bootout (recommended on macOS 11+)
launchctl bootout gui/$(id -u)/com.privaseeai.security-
Load the service:
launchctl load ~/Library/LaunchAgents/com.privaseeai.security.plist -
Check if it's running:
launchctl list | grep com.privaseeai.security ps aux | grep "privaseeai_security.orchestrator"
-
Verify logs are being written:
tail -f /var/log/privaseeai/security.log
You should see startup messages like:
INFO - Starting PrivaseeAI Security Orchestrator daemon... INFO - ✅ Orchestrator daemon started
Test the auto-restart functionality:
-
Find the service PID:
launchctl list | grep com.privaseeai.security # Note the PID (first column)
-
Kill the process:
kill -9 <PID>
-
Wait 60 seconds (ThrottleInterval), then check:
launchctl list | grep com.privaseeai.securityThe service should have a new PID, indicating it restarted automatically.
-
Check logs for restart:
grep -A 5 "Orchestrator daemon started" /var/log/privaseeai/security.log | tail -20
Test auto-start on boot:
- Reboot your system
- After login, check service status:
launchctl list | grep com.privaseeai.security tail /var/log/privaseeai/security.log
Test running the orchestrator manually (without launchd):
# Run directly
cd /opt/privaseeai
python3 -m privaseeai_security.orchestrator
# Should start and show logs in terminal
# Press Ctrl+C to stop-
Check Python installation:
which python3 /usr/bin/python3 --version # Should be 3.11+ -
Verify package installation:
python3 -c "import privaseeai_security; print(privaseeai_security.__version__)" -
Check permissions:
ls -la /var/log/privaseeai/ ls -la /opt/privaseeai/
-
View system logs:
log show --predicate 'process == "launchd"' --last 5m | grep privaseeai
-
Check error logs:
tail -50 /var/log/privaseeai/security.log
-
Test manual execution:
cd /opt/privaseeai python3 -m privaseeai_security.orchestrator -
Check for missing dependencies:
python3 -c "from privaseeai_security.orchestrator import ThreatOrchestrator"
-
Verify log directory permissions:
ls -la /var/log/privaseeai/
-
Check if process can write:
sudo -u $(whoami) touch /var/log/privaseeai/test.log rm /var/log/privaseeai/test.log -
Ensure PYTHONUNBUFFERED is set (already in plist)
- Label:
com.privaseeai.security- Unique service identifier - RunAtLoad:
true- Start on boot/load - KeepAlive: Configured to restart on any exit
- ThrottleInterval:
60seconds - Prevents rapid restart loops - WorkingDirectory:
/opt/privaseeai- Where service runs from - StandardOutPath/StandardErrorPath:
/var/log/privaseeai/security.log- Log location - LimitLoadToSessionType:
Aqua- User agent (not system daemon)
The plist includes:
PATH: Standard system PATHPYTHONUNBUFFERED:1- Force unbuffered output for immediate logs
If you use a virtual environment:
-
Edit the plist file:
<key>ProgramArguments</key> <array> <string>/path/to/your/venv/bin/python3</string> <string>-m</string> <string>privaseeai_security.orchestrator</string> </array>
-
Reload the service:
launchctl unload ~/Library/LaunchAgents/com.privaseeai.security.plist launchctl load ~/Library/LaunchAgents/com.privaseeai.security.plist
Modify the plist to pass backup path as environment variable:
<key>EnvironmentVariables</key>
<dict>
<!-- existing vars -->
<key>PRIVASEE_BACKUP_PATH</key>
<string>/path/to/ios/backups</string>
</dict>Then update orchestrator.py to read this environment variable.
Change crash recovery timing:
<key>ThrottleInterval</key>
<integer>120</integer> <!-- Wait 2 minutes instead of 60 seconds -->To completely remove the service:
# 1. Unload the service
launchctl unload ~/Library/LaunchAgents/com.privaseeai.security.plist
# 2. Remove the plist file
rm ~/Library/LaunchAgents/com.privaseeai.security.plist
# 3. (Optional) Remove log files
sudo rm -rf /var/log/privaseeai/
# 4. (Optional) Remove working directory
sudo rm -rf /opt/privaseeai/- Never store secrets in the plist file - Use environment files or macOS Keychain
- Limit log file permissions - Only the service user should read/write logs
- Regularly rotate logs - Use
newsyslogor similar tools - Monitor for unusual behavior - Check logs regularly for errors
For issues or questions:
- Check logs:
/var/log/privaseeai/security.log - GitHub Issues: https://github.com/aurelianware/PrivaseeAI.Security/issues
- Documentation: See README.md and USER_GUIDE.md
# Install
cp com.privaseeai.security.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.privaseeai.security.plist
# Status
launchctl list | grep com.privaseeai.security
# Logs
tail -f /var/log/privaseeai/security.log
# Restart
launchctl stop com.privaseeai.security
# Uninstall
launchctl unload ~/Library/LaunchAgents/com.privaseeai.security.plist
rm ~/Library/LaunchAgents/com.privaseeai.security.plist