I searched all over for an OSX native way to autolaunch my webapp upon
booting but found absolutely no mention of it. So here is my solution
using the (very elegant) launchd system.
Create a plist in folder:
/Library/LaunchDaemons/
with whatever name makes sense. May also work in your userfolder at
~/Library/LaunchDaemons/
Please report on that option.
Paste text like this into the file:
<?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>com.sectrum.app</string>
<key>ProgramArguments</key>
<array>
<string>/usr/python2.6</string>
<string>/absolute/path/to/Sectrum.py</string>
<string>8080</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/absolute/path/to/SectrumError.log</string>
<key>StandardErrorPath</key>
<string>/absolute/path/to/SectrumAccess.log</string>
</dict>
</plist>
Once you save the file it is easier to open it in Property List Editor
to customize the values.
A few notes on this plist:
1) I am forcing the webapp to run under python2.6
2) The target port MUST be included or the webapp won't start
3) StandardOutPath is evidently the error log, but unconfirmed
4) Webpy is writing the server log to StandardErrorPath
After every saving the file with Property List Editor you may need to
update the permissions, since launchd is very finicky about security:
sudo chmod 644 /Library/LaunchDaemons/SectrumWebApp.plist
sudo chown root:wheel /Library/LaunchDaemons/SectrumWebApp.plist
Start the job on the command line:
sudo launchctl load /Library/LaunchDaemons/SectrumWebApp.plist
Stop the job:
sudo launchctl unload /Library/LaunchDaemons/SectrumWebApp.plist
If it works as expected, reboot and see if you get http://0.0.0.0:8080
-- Gnarlie
http://Gnarlodious.com/
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.