If you’re using salt to ensure you’re running your services and you constantly see your service being started it might be because the service doesn’t support the status command.
---------- State: - service Name: openerp Function: running Result: True Comment: Started Service openerp Changes: openerp: True
If you tweak the salt minion to log trace messages you’ll see that salt calls service openerp status.
/etc/salt/minion: log_level: trace # service salt-minion restart /var/log/salt/minion 2013-10-02 19:26:32,602 [salt.loaded.int.module.cmdmod][INFO ] Executing command 'service openerp status' in directory '/root' 2013-10-02 19:26:32,611 [salt.loaded.int.module.cmdmod][INFO ] Executing command 'service openerp start' in directory '/root'
If we try that on the command line we’ll see that the openerp service doesn’t support the status option.
root@openerp-aq:~# service openerp status Usage: openerp-server {start|stop|restart|force-reload}
That means salt gets an error and assumes the service isn’t running so it starts it.
The service state has an alternative way to check for the service running by looking at ps
and grepping for the process. This is done by specifying the sig
key.
openerp: service: - running - sig: openerp - require: - pkg: openerp
Now we finally see what we want, salt leaving the service running.
---------- State: - service Name: openerp Function: running Result: True Comment: The service openerp is already running Changes:
In the log we now see,
2013-10-02 19:31:15,371 [salt.loaded.int.module.cmdmod][INFO ] Executing command "ps -efH | grep 'openerp' | grep -v grep | awk '{print $2}'" in directory '/root'