Or you could just run web.py under Apache/mod_wsgi where you use Apple supplied Apache. All you need to do is then go into System Preferences and enable web sharing to ensure Apache started on reboot.
Graham On Mar 6, 5:31 pm, Gnarlodious <[email protected]> wrote: > 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 gethttp://0.0.0.0:8080 > > -- Gnarliehttp://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.
