mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-07 17:40:30 +00:00
Move server control code to the top
This commit is contained in:
parent
4582ea1498
commit
51e9e29b24
1 changed files with 26 additions and 23 deletions
|
@ -61,6 +61,32 @@ class Server(object):
|
|||
|
||||
daemon.requestLoop(loopCondition=lambda: not self.stop_serving)
|
||||
|
||||
@Pyro4.expose
|
||||
def set_callback_server(self, server):
|
||||
log.debug('Forwarding logs to the callback server')
|
||||
self.log_forwarder.set_server(server)
|
||||
|
||||
@Pyro4.expose
|
||||
def ping(self):
|
||||
if hasattr(self, 'connection_timeout'):
|
||||
self.connection_timeout.cancel()
|
||||
del self.connection_timeout
|
||||
return 'pong'
|
||||
|
||||
@Pyro4.expose
|
||||
def stop(self):
|
||||
if hasattr(self, 'bootstrap_process'):
|
||||
log.warn('Sending SIGINT to bootstrapping process')
|
||||
import os
|
||||
import signal
|
||||
os.killpg(self.bootstrap_process.pid, signal.SIGINT)
|
||||
self.bootstrap_process.join()
|
||||
|
||||
# We can't send a SIGINT to the server,
|
||||
# for some reason the Pyro4 shutdowns are rather unclean,
|
||||
# throwing exceptions and such.
|
||||
self.stop_serving = True
|
||||
|
||||
@Pyro4.expose
|
||||
def run(self, manifest, debug=False, dry_run=False):
|
||||
|
||||
|
@ -102,26 +128,3 @@ class Server(object):
|
|||
if isinstance(result, Exception):
|
||||
raise result
|
||||
return result
|
||||
|
||||
@Pyro4.expose
|
||||
def set_callback_server(self, server):
|
||||
log.debug('Forwarding logs to the callback server')
|
||||
self.log_forwarder.set_server(server)
|
||||
|
||||
@Pyro4.expose
|
||||
def ping(self):
|
||||
return 'pong'
|
||||
|
||||
@Pyro4.expose
|
||||
def stop(self):
|
||||
if hasattr(self, 'bootstrap_process'):
|
||||
log.warn('Sending SIGINT to bootstrapping process')
|
||||
import os
|
||||
import signal
|
||||
os.killpg(self.bootstrap_process.pid, signal.SIGINT)
|
||||
self.bootstrap_process.join()
|
||||
|
||||
# We can't send a SIGINT to the server,
|
||||
# for some reason the Pyro4 shutdowns are rather unclean,
|
||||
# throwing exceptions and such.
|
||||
self.stop_serving = True
|
||||
|
|
Loading…
Add table
Reference in a new issue