basho/node_package — pull request #51 by jaredmorrow (2013-05-10 14:08:12+00:00)
Title: Return nonzero exit codes on init function failure

Addresses #40

The Debian policy is vague on "proper" exit codes, many times
going against the LSB. See http://wiki.debian.org/LSBInitScripts
for reference. This commit goes with the LSB to at least return
nonzero exit codes on start/stop/reload/restart functions.

Here is the behavior in testing

```
➜ init.d sudo ./riak start
!!!!
!!!! WARNING: ulimit -n is 1024; 4096 is the recommended minimum.
!!!!
➜ init.d echo $?
0
➜ init.d sudo ./riak ping
pong
➜ init.d echo $?
0
➜ init.d sudo ./riak stop
ok
➜ init.d echo $?
0
➜ init.d sudo ./riak ping
Node 'riak@127.0.0.1' not responding to pings.
➜ init.d echo $?
1
➜ init.d sudo emacs /etc/riak/app.config # edit config here to fail
➜ init.d head -5 /etc/riak/app.config
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
[ parse,error,in,the,house]]]]]
%% Riak Client APIs config
{riak_api, [
➜ init.d sudo ./riak ping
Node 'riak@127.0.0.1' not responding to pings.
➜ init.d sudo ./riak start
Error on line 3: syntax error before: ']'
Error reading /etc/riak/app.config
➜ init.d echo $?
1
➜ init.d sudo ./riak stop
Node 'riak@127.0.0.1' not responding to pings.
Node is not running!
➜ init.d echo $?
0
➜ init.d sudo ./riak ping
Node 'riak@127.0.0.1' not responding to pings.
➜ init.d echo $?
1
➜ init.d sudo ./riak restart
* Restarting Riak is a distributed data store riak Node 'riak@127.0.0.1' not responding to pings.
Node is not running!
Error on line 3: syntax error before: ']'
Error reading /etc/riak/app.config
➜ init.d echo $?
0
```

The final return code of "0" is correct on a restart when the node isn't running to begin with.