CC-4114: use liquidsoap shutdown() command to restart liquidsoap

-changed to use init.d script to restart.
This commit is contained in:
Martin Konecny 2012-08-19 00:41:25 -04:00
parent 1dd1ba4420
commit 72de78bcd1
2 changed files with 7 additions and 18 deletions

View File

@ -130,7 +130,7 @@ def liquidsoap_running_test(telnet_lock, host, port, logger):
msg = "version\n"
tn.write(msg)
tn.write("exit\n")
logger.info("Liquidsoap version %s", tn.read_all())
logger.info("Found: %s", tn.read_all())
except Exception, e:
logger.error(str(e))
success = False
@ -210,7 +210,7 @@ if __name__ == '__main__':
recorder.start()
# all join() are commented out because we want to exit entire pypo
# if pypofetch is exiting
# if pypofetch is exiting
#pmh.join()
#recorder.join()
#pp.join()

View File

@ -205,22 +205,11 @@ class PypoFetch(Thread):
fh.write("log_file = \"/var/log/airtime/pypo-liquidsoap/<script>.log\"\n");
fh.close()
def stop_liquidsoap(self):
self.telnet_lock.acquire()
def restart_liquidsoap(self):
try:
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
# update the boot up time of liquidsoap. Since liquidsoap is not restarting,
# we are manually adjusting the bootup time variable so the status msg will get
# updated.
tn.write("system.shutdown\n")
tn.write('exit\n')
output = tn.read_all()
subprocess.call('/etc/init.d/airtime-liquidsoap restart', shell=True)
except Exception, e:
self.logger.error(str(e))
finally:
self.telnet_lock.release()
self.logger.error(e)
def regenerate_liquidsoap_conf(self, setting):
existing = {}
@ -232,7 +221,7 @@ class PypoFetch(Thread):
except IOError, e:
#file does not exist
self.write_liquidsoap_config(setting)
self.stop_liquidsoap()
self.restart_liquidsoap()
self.logger.info("Reading existing config...")
# read existing conf file and build dict
@ -313,7 +302,7 @@ class PypoFetch(Thread):
# rewrite
if restart:
self.write_liquidsoap_config(setting)
self.stop_liquidsoap()
self.restart_liquidsoap()
else:
self.logger.info("No change detected in setting...")
self.update_liquidsoap_connection_status()