2.4 – Install as macOS daemon
Run the following commands:
-
cd /Library -
sudo unzip SparkGateway.zip -
sudo chown username SparkGatewayusername should be the login name under which gateway will run -
sudo chgrp admin SparkGateway -
cd SparkGateway -
sudo nano start.shwith following content:
#!/bin/sh SPARK_HOME=/Library/SparkGateway java -jar $SPARK_HOME/SparkGateway.jar -c=$SPARK_HOME/gateway.conf - Save the file and run
sudo chmod a+x start.sh - Change the default directory and listening port if port 80 is occupied in gateway.conf:
port = 8080 logfile = /Library/SparkGateway/logs/gateway.log html = /Library/SparkGateway/html license = /Library/SparkGateway/license - Use
sudo ./start.shto test if there are any errors within the script. -
cd /Library/LaunchDaemons -
sudo nano com.toremote.gateway.plistwith following content:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.toremote.gateway</string> <key>Disabled</key> <false/> <key>OnDemand</key> <false/> <key>RunAtLoad</key> <true/> <key>ProgramArguments</key> <array> <string>/Library/SparkGateway/start.sh</string> </array> <key>EnvironmentVariables</key> <dict> <key>SPARK_HOME</key> <string>/Library/SparkGateway</string> </dict> <key>StandardErrorPath</key> <string>/Library/SparkGateway/logs/gateway.stderr</string> <key>StandardOutPath</key> <string>/Library/SparkGateway/logs/gateway.stdout</string> <key>UserName</key> <string>_appserver</string> </dict> </plist> - Service commands:
- Load the service:
sudo launchctl load /Library/LaunchDaemons/com.toremote.gateway.plist - Unload the service:
sudo launchctl unload /Library/LaunchDaemons/com.toremote.gateway.plist