Mac actually has a pretty nice way to run programs as daemons. Similar to upstart on linux, but better.<br>You need a .plist xml. Something like this:<br><br><?xml version="1.0" encoding="UTF-8"?><br>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "<a href="http://www.apple.com/DTDs/PropertyList-1.0.dtd">http://www.apple.com/DTDs/PropertyList-1.0.dtd</a>"><br><plist version="1.0"><br>
<dict><br> <key>Label</key><br> <string>NAME_OF_YOUR_PROGRAM</string><br> <key>EnvironmentVariables</key><br> <dict><br> <key>HOME</key><br> <string>~</string><br>
</dict><br> <key>OnDemand</key><br> <false/><br> <key>ProgramArguments</key><br> <array><br> <string>EXEC_WORD1</string><br> <string>EXEC_WORD2</string><br>
<string>EXEC_WORDX</string><br> </array><br> <key>RunAtLoad</key><br> <true/><br> <key>KeepAlive</key><br> <true/><br> <key>UserName</key><br>
<string>NAME_OF_USER_TO_RUN_AS</string><br> <key>Group</key><br> <string>NAME_OF_GROUP_TO_RUN_AS</string><br></dict><br></plist><br><br>For every word in your execution line, you need a separate <string> in ProgramArguments.<br>
Add it to /Library/LaunchDaemons/yourxml.plist<br>If it's there, it will be executed on startup.<br><br>To load (run): sudo launchctl load /Library/LaunchDaemons/yourxml.plist<br>To unload (stop): sudo launchctl unload /Library/LaunchDaemons/yourxml.plist<br>
<br>I usually put the erl execution in a bash script and execute the script in the plist.<br><br>#!/bin/sh<br>cd /Path/To/My/Ebin<br>erl +Bd +P 1000000 -env ERL_MAX_PORTS 100000 -noinput +K true +A 32 -mnesia dir '"/Path/To/My/priv/mnesia"' -eval "application:start(MY_APP,permanent)"<br>
<br>You can even see what your program is printing to stdout. If you run /Applications/Utilities/Console -> Console Messages<br><br><a href="http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Articles/LaunchOnDemandDaemons.html">http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Articles/LaunchOnDemandDaemons.html</a><br>
<br><br>Sergej<br><br><div class="gmail_quote">On Mon, Mar 28, 2011 at 6:09 AM, Joe Armstrong <span dir="ltr"><<a href="mailto:erlang@gmail.com">erlang@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I want to run a resident distributed erlang node on my macbook.<div>It should be started when I reboot my machine. </div><div>It should be restarted if it crashes. Nothing nasty should happen when I open/close</div><div>the lid :-) (I guess I also need to "manage" the node occasional - so I'd need some</div>
<div>remote control facilities)</div><div><br></div><div>What is "best practice" for doing this - does anybody maintain scripts of this nature?</div><div><br></div><div>(aside it strikes me that this cannot be an uncommon problem - since we are now in</div>
<div>uncharted "OS specific" territory it would be nice to know the answer to this question</div><div>for all the other "popular" OSs - any tips ?)</div><div><br></div><font color="#888888"><div>/Joe</div>
</font><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br>