Skip to main content

2.4 – Install as macOS daemon

Run the following commands:

  1. cd /Library
  2. sudo unzip SparkGateway.zip
  3. sudo chown username SparkGateway username should be the login name under which gateway will run
  4. sudo chgrp admin SparkGateway
  5. cd SparkGateway
  6. sudo nano start.sh with following content:
    #!/bin/sh
    SPARK_HOME=/Library/SparkGateway
    java -jar $SPARK_HOME/SparkGateway.jar -c=$SPARK_HOME/gateway.conf
    
  7. Save the file and run sudo chmod a+x start.sh
  8. 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
    
  9. Use sudo ./start.sh to test if there are any errors within the script.
  10. cd /Library/LaunchDaemons
  11. sudo nano com.toremote.gateway.plist with 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>
    
  12. 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