Running riak from launchd?

Izzy Alanis izzyalanis at gmail.com
Sat May 26 10:38:13 EDT 2012


Has anyone gotten riak to run under launchd?

Or, is there a way to run riak in console mode without the interactive
erlang shell?

Launchd doesn't want its subprocesses to daemonize themselves. If I
set up a launch file to run riak in the foreground with "riak
console", its the same as running "riak console < /dev/null"  from the
command line, and (I'm guessing here:) the interactive shell sees the
end of stream and ends the console session.

I expect you'd have the same problem using supervisor as your process
controller. Supervisor has a pixproxy program to help in these sort of
situations, but riak is not writing out a pid file either(?!).

Things I've tried:

Piping input from /dev/zero is understandably disastrous:
> riak console < /dev/zero

Piping input from a fifo just hangs:
> mkfifo < /tmp/myfifo
> riak console < /tmp/myfifo

This seems to mostly work (or might really work well with some extra
bash scripting):
> mkfifo < /tmp/myfifo
> echo > /tmp/myfifo &
> riak console < /tmp/myfifo
I have that last one in a wrapper script. I could add the bells and
whistles to make the fifo a random filename and make sure it gets
cleaned up after the script end, etc, etc, etc.

Here's my launch config (below), FYI. I'm running it out of
/Library/LaunchDaemons, and errang *really* wants a HOME environment
variable which is a gotcha for anybody else out there!:

Anybody else get something like this working?

<?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>com.basho.riak</string>
	<key>OnDemand</key>
	<false/>
	<key>Program</key>
	<string>/opt/riak/bin/riak-wrapper</string>
	<key>EnvironmentVariables</key>
	<dict>
		<key>HOME</key>
		<string>/opt/riak/</string>
	</dict>
	<key>StandardOutPath</key>
	<string>/opt/riak/log/console.log</string>
	<key>StandardErrorPath</key>
	<string>/opt/riak/log/error.log</string>
	<key>SoftResourceLimits</key>
	<dict>
		<key>NumberOfFiles</key>
		<integer>4096</integer>
	</dict>
	<key>HardResourceLimits</key>
	<dict>
		<key>NumberOfFiles</key>
		<integer>4096</integer>
	</dict>
</dict>
</plist>




More information about the riak-users mailing list