[erlang-questions 77] Re: starting and managing a resident erlang server on mac (or other OSs)

Michael Truog <>
Mon Mar 28 09:50:32 CEST 2011


The rebar release includes a script that should be suitable for running the Erlang system as a daemon on OSX.
The command sequence is here: https://bitbucket.org/basho/rebar/wiki/ReleaseHandling
The configuration files I currently like are here (which are largely defaults):
https://github.com/okeuday/CloudI/blob/master/src/reltool.config.in     (normal name is reltool.config)
https://github.com/okeuday/CloudI/blob/master/src/rebar.config

On 03/27/2011 09:41 PM, Rapsey wrote:
> Mac actually has a pretty nice way to run programs as daemons. Similar to upstart on linux, but better.
> You need a .plist xml. Something like this:
>
> <?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>NAME_OF_YOUR_PROGRAM</string>
>     <key>EnvironmentVariables</key>
>     <dict>
>       <key>HOME</key>
>       <string>~</string>
>     </dict>
>     <key>OnDemand</key>
>     <false/>
>     <key>ProgramArguments</key>
>     <array>
>         <string>EXEC_WORD1</string>
>         <string>EXEC_WORD2</string>
>         <string>EXEC_WORDX</string>
>     </array>
>     <key>RunAtLoad</key>
>     <true/>
>     <key>KeepAlive</key>
>         <true/>
>         <key>UserName</key>
>         <string>NAME_OF_USER_TO_RUN_AS</string>
>         <key>Group</key>
>         <string>NAME_OF_GROUP_TO_RUN_AS</string>
> </dict>
> </plist>
>
> For every word in your execution line, you need a separate <string> in ProgramArguments.
> Add it to /Library/LaunchDaemons/yourxml.plist
> If it's there, it will be executed on startup.
>
> To load (run): sudo launchctl load /Library/LaunchDaemons/yourxml.plist
> To unload (stop): sudo launchctl unload /Library/LaunchDaemons/yourxml.plist
>
> I usually put the erl execution in a bash script and execute the script in the plist.
>
> #!/bin/sh
> cd /Path/To/My/Ebin
> 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)"
>
> You can even see what your program is printing to stdout. If you run /Applications/Utilities/Console -> Console Messages
>
> http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Articles/LaunchOnDemandDaemons.html
>
>
> Sergej
>
> On Mon, Mar 28, 2011 at 6:09 AM, Joe Armstrong < <mailto:>> wrote:
>
>     I want to run a resident distributed erlang node on my macbook.
>     It should be started when I reboot my machine. 
>     It should be restarted if it crashes. Nothing nasty should happen when I open/close
>     the lid :-) (I guess I also need to "manage" the node occasional - so I'd need some
>     remote control facilities)
>
>     What is "best practice" for doing this - does anybody maintain scripts of this nature?
>
>     (aside it strikes me that this cannot be an uncommon problem - since we are now in
>     uncharted "OS specific" territory it would be nice to know the answer to this question
>     for all the other "popular" OSs - any tips ?)
>
>     /Joe
>
>     _______________________________________________
>     erlang-questions mailing list
>      <mailto:>
>     http://erlang.org/mailman/listinfo/erlang-questions
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110328/dcd42c3f/attachment.html>


More information about the erlang-questions mailing list