the fast, reliable localhost tunneling solution


Installing pagekite as a launchctl service

2011-04-30, 17:12

The goal here is to have an OSX pagekite backend run automatically when the system starts up. Inspired by the DebianPackage, these instruction put pagekite.py in /usr/bin and the config file at /etc/pagekite/pagekite.rc.

Installing

Download pagekite.py. You'll need to change the permissions to make it system runnable, and then put it in /usr/bin.

 wget --no-check-certificate http://pagekite.net/pk/pagekite.py
 chmod +x pagekite.py
 sudo chown root:wheel pagekite.py
 mv pagekite.py /usr/bin/pagekite.py

Download a sample pagekite.rc config file, or configure one however you like - nothing special should need to be changed for OSX.

  mkdir /etc/pagekite/
  mv .pagekite.rc /etc/pagekite/pagekite.rc

Now add pagekite.py as a launchctl service, pointing it to the options file:

 sudo launchctl submit -l pagekite -- pagekite.py --clean -o /etc/pagekite/pagekite.rc

Starting and Stopping

Now that it's installed with launchctl, pagekite.py should start whenever the system boots up, and even if pagekite.py crashes it should be restarted. These commands may be helpful:

sudo launchctl start pagekite
sudo launchctl stop pagekite
sudo launchctl remove pagekite

[ Back to How-Tos ]

Comments

  1. Jon said on 2011-11-02, 19:09
    There's a typo in this line:

    sudo launchtl submit -l pagekite -- pagekite.py --clean -o /etc/pagekite/pagekite.rc

    Should be:

    sudo launchctl submit -l pagekite -- pagekite.py --clean -o /etc/pagekite/pagekite.rc
    Permalink
  2. Laurent said on 2012-06-23, 01:05
    Hello !

    I tried to install pagekite as a service, the service works after executing the above command "sudo launchctl submit -l pagekite -- pagekite.py --clean -o /etc/pagekite/pagekite.rc" but doesn't restart after a reboot.

    Do you have an idea of what I am missing ?

    Cheers.
    Permalink
  3. Bjarni RĂșnar Einarsson said on 2012-06-23, 13:13
    Just a guess, but perhaps you need to give the full path to pagekite.py in the launchctl command?
    Permalink
  4. OderWat (ADN/Twitter @OderWat) said on 2013-09-27, 13:47
    This wiki entry is not very useful!

    launchctl with argument "submit" is not creating anything which survives a reboot.

    "submit" by default also will use the keep alive functionality. So the mentioned "launchctl stop" will in effect not stop the demon but kinda restart it as launchd will restart the process if it is being stopped.

    To stop the daemon you need to use "remove" but this will not left anything over to "start" it again.

    To really create a daemon which survives a reboot you have to create a plist file in /Library/LaunchDaemons which will add this daemon to the global daemons which are run at boot time by launchd.

    Meanwhile I am working on a Blog entry with the detailed instructions. You may consider updating the wiki to something more useful!
    Permalink
  5. Micah Geisel said on 2015-11-21, 00:21
    Confirmed. Launchctl instructions didn't create the service correctly. Instead, I needed to create a file at /Library/LaunchDaemons/pagekite.service.plist with the following contents:

    <?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>pagekite.service</string>

    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/bin/pagekite.py</string>
    <string>--optfile=/etc/pagekite/pagekite.rc</string>
    </array>

    <key>KeepAlive</key>
    <true/>

    <key>RunAtLoad</key>
    <true/>
    </dict>
    </plist>

    Then, to install the service, run:

    sudo launchctl load /Library/LaunchDaemons/pagekite.service.plist
    Permalink

Leave a comment

( (Please leave these blank: )

We use Gravatar for commenter's photos. Get your own, it's free!

Wiki

Links