Skip to content

Commit

Permalink
Added auto restarting to the main.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
CEbbinghaus committed Nov 27, 2023
1 parent 12ef1f6 commit c9eae63
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@ class Plugin:
# Asyncio-compatible long-running code, executed in a task when the plugin is loaded
async def _main(self):
# startup
self.backend_proc = subprocess.Popen([PARENT_DIR + "/bin/backend"])
while True:
await asyncio.sleep(1)
self.return_code = None
self.backend_proc = subprocess.Popen([PARENT_DIR + "/bin/backend"])

while True:
if(self.backend_proc.returncode != None):
self.return_code = self.backend_proc.returncode
break
await asyncio.sleep(1)

match self.return_code:
# SIGKILL, SIGTERM, The Process was killed by the user
case 137 | 143:
break

# SIGABRT The program is assumed to have crashed
case 134:
print("SIGABRT was returned")

# The Program exited normally? This happens when its cancelled with Ctrl+C or
# one of the threads exited without an error. Restart for good measure
case 0:
print("Program exited successfully")

case _code:
print("Program exited with exit code: " + _code)
break;

0 comments on commit c9eae63

Please sign in to comment.