def POST(self): # 'startsecs=0' is to avoid restarting consul after `consul leave`. os.system('sed -i \'/autorestart=true/cautorestart=false\' /etc/supervisor/conf.d/consul.conf') os.system('echo startsecs=0 >> /etc/supervisor/conf.d/consul.conf') os.system('supervisorctl update consul') # As 'supervisorctl update' will restart Consul, we have to wait for it to be running. while True: try: get_current_datacenter() break except: pass deregister_services(gethostname()) os.system('consul leave') return self.status_ok({'message': 'Shutdown complete.'})
def POST(self): # Wpisujemy 'startsecs=0', zeby ubicie consula przez 'consul leave' nie spowodowalo jego restartu. os.system('sed -i \'/autorestart=true/cautorestart=false\' /etc/supervisor/conf.d/consul.conf') os.system('echo startsecs=0 >> /etc/supervisor/conf.d/consul.conf') os.system('supervisorctl update consul') # 'supervisorctl update' zrestartuje consula. Czekamy az wystartuje na nowo. while True: try: get_current_datacenter() break except: pass deregister_services(gethostname()) os.system('consul leave') return self.status_ok({'message': 'Shutdown complete.'})
def POST(self): # 'startsecs=0' is to avoid restarting consul after `consul leave`. os.system( 'sed -i \'/autorestart=true/cautorestart=false\' /etc/supervisor/conf.d/consul.conf' ) os.system('echo startsecs=0 >> /etc/supervisor/conf.d/consul.conf') os.system('supervisorctl update consul') # As 'supervisorctl update' will restart Consul, we have to wait for it to be running. while True: try: get_current_datacenter() break except: pass deregister_services(gethostname()) os.system('consul leave') return self.status_ok({'message': 'Shutdown complete.'})
def POST(self): # Wpisujemy 'startsecs=0', zeby ubicie consula przez 'consul leave' nie spowodowalo jego restartu. os.system( 'sed -i \'/autorestart=true/cautorestart=false\' /etc/supervisor/conf.d/consul.conf' ) os.system('echo startsecs=0 >> /etc/supervisor/conf.d/consul.conf') os.system('supervisorctl update consul') # 'supervisorctl update' zrestartuje consula. Czekamy az wystartuje na nowo. while True: try: get_current_datacenter() break except: pass deregister_services(gethostname()) os.system('consul leave') return self.status_ok({'message': 'Shutdown complete.'})