diff --git a/frpc.sh b/frpc.sh index 25542f7..e9a0627 100755 --- a/frpc.sh +++ b/frpc.sh @@ -10,16 +10,22 @@ trap quit EXIT # find frpc frpc=$(which "frpc") if [[ -z $frpc ]]; then - frpc=$(which "../frp-mac/latest/frpcx") + frpc=$(which "../frp-mac/latest/frpc") if [[ -z $frpc ]]; then - >&2 echo "frpc not found; try installing with 'brew install frpc'" + >&2 echo "Error: frpc not found; Try installing with 'brew install frpc'" exit 1 fi fi ->&2 echo "Using frpc: $frpc" ->&2 echo "Plotter URL (via frp): wss://plotter.process.tools" +if [[ ! -f ./frp.auth ]]; then + >&2 echo "Error: Missing frp auth file: frp.auth" + exit 1 +fi + source frp.auth # read auth token from file export FRP_AUTH_TOKEN +>&2 echo "Using frpc: $frpc" +>&2 echo "Plotter URL (via frp): wss://plotter.process.tools" + $frpc -c frpc.toml diff --git a/main.py b/main.py index b60e287..f0a9e76 100644 --- a/main.py +++ b/main.py @@ -274,14 +274,16 @@ def on_mount(self): server_task = asyncio.create_task(run_server(self)) def on_server_task_exit(task): - tprint('server task exit') + print('[red]Server task exit') if not task.cancelled(): # not a intentional exit ex = task.exception() if ex != None: import traceback - tprint('Server task exception:') - tprint(''.join(traceback.format_exception(ex))) - self.exit() + print('Server task exited with exception:') + print(''.join(traceback.format_exception(ex))) + global server_task_exception + server_task_exception = ex + self.exit() # This line can be removed, exception will then be show inside app log area server_task.add_done_callback(on_server_task_exit) @@ -561,7 +563,10 @@ def prompt_ui(self, variant, message = ''): if __name__ == "__main__": global print global tprint + global server_task_exception + tprint = print + server_task_exception = None if USE_PORKBUN: porkbun.ddns_update(PORKBUN_ROOT_DOMAIN, PORKBUN_SUBDOMAIN, PORKBUN_TTL) @@ -574,4 +579,10 @@ def prompt_ui(self, variant, message = ''): print = app.print app.tprint = tprint - app.run() \ No newline at end of file + app.run() + + print = tprint # restore print function + if server_task_exception != None: + print() + print("Server task exited with exception:") + raise server_task_exception \ No newline at end of file diff --git a/porkbun.py b/porkbun.py index fa979b2..7f839dd 100644 --- a/porkbun.py +++ b/porkbun.py @@ -15,6 +15,9 @@ def get_lanip(): return ipaddrlist[-1] def get_config(): + if not os.path.exists(CONFIG_FILE): + print(f"Error: Porkbun (DNS Service) config file is missing: {CONFIG_FILE}") + exit() with open(CONFIG_FILE) as f: api_config = json.load(f) return api_config diff --git a/spooler.py b/spooler.py index b7ef43c..66ab4ef 100644 --- a/spooler.py +++ b/spooler.py @@ -663,8 +663,12 @@ def attr(attr, ns = NS): async def resume_queue_from_disk(): import xml.etree.ElementTree as ElementTree - list = sorted(os.listdir(STATUS_FOLDERS['waiting'])) - list = [ os.path.join(STATUS_FOLDERS['waiting'], x) for x in list if x.endswith('.svg') ] + try: + list = sorted(os.listdir(STATUS_FOLDERS['waiting'])) + list = [ os.path.join(STATUS_FOLDERS['waiting'], x) for x in list if x.endswith('.svg') ] + except FileNotFoundError: + list = [] + resumable_jobs = [] for filename in list: # print('Loading ', filename) diff --git a/start b/start index cfdafac..871caeb 100755 --- a/start +++ b/start @@ -74,6 +74,12 @@ if $start_ngrok; then ngrok_pid=$! fi +# Try to activate venv +if [[ -f ./venv/bin/activate ]]; then + echo "Activating virtual env..." + source ./venv/bin/activate +fi + # run plotter-server if $dev; then textual run --dev main.py