Tom Duckering

Icon

a web log of my technical stumblings

Return code for init.d scripts status gotcha

I just ran into a problem with the Cassandra init.d script whereby it does not return the right status code when you ask it for Cassandra’s status. It returned a 0 when the service was stopped.

>/sbin/service cassandra stop
>/sbin/service cassandra status
> echo $?
0
>

However when you ask an init.d script for the status of a service it should return status codes based on the following rules:

https://fedoraproject.org/wiki/FCNewInit/Initscripts#Init_Script_Actions

It doesn’t present much of a problem if you’re installing and controlling your services manually. However when you start to use config management tools like Chef or Puppet then programmatic indication of service status is far more important. In this situation we were using Chef and it believes that the service is started when in fact it’s stopped.

Not the first time I’ve seen this issue.

Filed under: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: