comparison libervia/backend/core/launcher.py @ 4075:47401850dec6

refactoring: rename `libervia.frontends.jp` to `libervia.cli`
author Goffi <goffi@goffi.org>
date Fri, 02 Jun 2023 14:54:26 +0200
parents 4b842c1fb686
children 84f6bee6440d
comparison
equal deleted inserted replaced
4074:26b7ed2817da 4075:47401850dec6
71 sys.exit(0) 71 sys.exit(0)
72 try: 72 try:
73 pid = int(pid_file.read_text()) 73 pid = int(pid_file.read_text())
74 except Exception as e: 74 except Exception as e:
75 print(f"Can't read PID file at {pid_file}: {e}") 75 print(f"Can't read PID file at {pid_file}: {e}")
76 # we use the same exit code as DATA_ERROR in jp 76 # we use the same exit code as DATA_ERROR in CLI frontend
77 sys.exit(17) 77 sys.exit(17)
78 print(f"Terminating {self.APP_NAME}…") 78 print(f"Terminating {self.APP_NAME}…")
79 os.kill(pid, signal.SIGTERM) 79 os.kill(pid, signal.SIGTERM)
80 kill_started = time.time() 80 kill_started = time.time()
81 state = "init" 81 state = "init"
112 import errno 112 import errno
113 try: 113 try:
114 pid = int(pid_file.read_text()) 114 pid = int(pid_file.read_text())
115 except Exception as e: 115 except Exception as e:
116 print(f"Can't read PID file at {pid_file}: {e}") 116 print(f"Can't read PID file at {pid_file}: {e}")
117 # we use the same exit code as DATA_ERROR in jp 117 # we use the same exit code as DATA_ERROR in CLI frontend
118 sys.exit(17) 118 sys.exit(17)
119 # we check if there is a process 119 # we check if there is a process
120 # inspired by https://stackoverflow.com/a/568285 and https://stackoverflow.com/a/6940314 120 # inspired by https://stackoverflow.com/a/568285 and https://stackoverflow.com/a/6940314
121 try: 121 try:
122 os.kill(pid, 0) 122 os.kill(pid, 0)