Use service.reload instead of service.restart

1,962 views
Skip to first unread message

Sebastian

unread,
Aug 7, 2012, 10:08:28 AM8/7/12
to salt-...@googlegroups.com
Hi,

I found this line https://github.com/saltstack/salt/blob/develop/salt/states/service.py#L367 in the source code of Salt, but don’t know how to use it in my Apache2 state file. The watcher should reload Apache2 instead of restarting it when someone changes the config files. Any idea?

Here is my state file:

apache2:
  pkg:
    - latest
  service:
    - running
    - watch:
      - file: /etc/apache2/apache2.conf
      - file: /etc/apache2/httpd.conf
    - require:
      - pkg: apache2 

Thomas S Hatch

unread,
Aug 7, 2012, 1:29:07 PM8/7/12
to salt-...@googlegroups.com
Arguments in sls files get passed into the mod_watch function if the mod_watch function accepts them:

apache2:
  pkg:
    - latest
  service:
    - running
    - reload: True
    - watch:
      - file: /etc/apache2/apache2.conf
      - file: /etc/apache2/httpd.conf
    - require:
      - pkg: apache2 


Avi Marcus

unread,
Aug 7, 2012, 4:57:41 PM8/7/12
to salt-...@googlegroups.com
... so this needs to be doc'd somewhere?
And I believe not all systems support the reload arg?

-Avi

Thomas S Hatch

unread,
Aug 8, 2012, 11:45:37 AM8/8/12
to salt-...@googlegroups.com
Correct, only if the system has a reload function in the relative service module, and yes, this needs to be documented.

Jeroen Dekkers

unread,
Aug 8, 2012, 12:32:15 PM8/8/12
to salt-...@googlegroups.com
Wouldn't it be better if reload was the default? If you change a
config file, you almost always want to reload the daemon instead of
restarting it.

At Wed, 8 Aug 2012 09:45:37 -0600,

Avi Marcus

unread,
Aug 8, 2012, 3:07:54 PM8/8/12
to salt-...@googlegroups.com
Not all init scripts and/or the actual software support hot-reloading.
-Avi

Jeroen Dekkers

unread,
Aug 8, 2012, 4:04:32 PM8/8/12
to salt-...@googlegroups.com
At Wed, 8 Aug 2012 22:07:54 +0300,
Avi Marcus wrote:
> Not all init scripts and/or the actual software support hot-reloading.

You're right, we should use force-reload (at least on Linux):

http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html

It will reload the service if that is supported and restart
otherwise. I guess that is precisely what we want.


Kind regards,

Jeroen Dekkers

Avi Marcus

unread,
Aug 8, 2012, 4:10:30 PM8/8/12
to salt-...@googlegroups.com
Oh cool, monit's init.d has force-reload, even though it doesn't have reload.
-Avi

Thomas S Hatch

unread,
Aug 8, 2012, 10:25:38 PM8/8/12
to salt-...@googlegroups.com
I would love to use fore-reload, but the underlying init scripts and init system will need to use it, and this is not always the case
Reply all
Reply to author
Forward
0 new messages