mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Handle Ctrl-c on the syndic or regular minion and log it
- Log a message when the syndic or minion is exiting - Cleanly exit and use the same message on all daemons - Add places to handle a sigterm or sighup by KeyboardInterrupt
This commit is contained in:
parent
c1b3ee3580
commit
bb0629e690
2 changed files with 25 additions and 18 deletions
|
@ -93,6 +93,7 @@ class Master(object):
|
|||
for name, level in self.opts['log_granular_levels'].iteritems():
|
||||
salt.log.set_logger_level(name, level)
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
# Late import so logging works correctly
|
||||
import salt.master
|
||||
master = salt.master.Master(self.opts)
|
||||
|
@ -162,12 +163,17 @@ class Minion(object):
|
|||
|
||||
# Late import so logging works correctly
|
||||
import salt.minion
|
||||
if self.cli['daemon']:
|
||||
# Late import so logging works correctly
|
||||
import salt.utils
|
||||
salt.utils.daemonize()
|
||||
minion = salt.minion.Minion(self.opts)
|
||||
minion.tune_in()
|
||||
log = logging.getLogger(__name__)
|
||||
try:
|
||||
if self.cli['daemon']:
|
||||
# Late import so logging works correctly
|
||||
import salt.utils
|
||||
salt.utils.daemonize()
|
||||
minion = salt.minion.Minion(self.opts)
|
||||
minion.tune_in()
|
||||
except KeyboardInterrupt:
|
||||
log.warn('Stopping the Salt Minion')
|
||||
raise SystemExit('\nExiting on Ctrl-c')
|
||||
|
||||
|
||||
class Syndic(object):
|
||||
|
@ -259,9 +265,14 @@ class Syndic(object):
|
|||
|
||||
# Late import so logging works correctly
|
||||
import salt.minion
|
||||
syndic = salt.minion.Syndic(self.opts)
|
||||
if self.cli['daemon']:
|
||||
# Late import so logging works correctly
|
||||
import salt.utils
|
||||
salt.utils.daemonize()
|
||||
syndic.tune_in()
|
||||
log = logging.getLogger(__name__)
|
||||
try:
|
||||
syndic = salt.minion.Syndic(self.opts)
|
||||
if self.cli['daemon']:
|
||||
# Late import so logging works correctly
|
||||
import salt.utils
|
||||
salt.utils.daemonize()
|
||||
syndic.tune_in()
|
||||
except KeyboardInterrupt:
|
||||
log.warn('Stopping the Salt Syndic Minion')
|
||||
raise SystemExit('\nExiting on Ctrl-c')
|
||||
|
|
|
@ -11,12 +11,8 @@ def main():
|
|||
'''
|
||||
The main function
|
||||
'''
|
||||
pid = os.getpid()
|
||||
try:
|
||||
minion = salt.Minion()
|
||||
minion.start()
|
||||
except KeyboardInterrupt:
|
||||
os.kill(pid, 15)
|
||||
minion = salt.Minion()
|
||||
minion.start()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Reference in a new issue