diff --git a/app/apps/cache.py b/app/apps/cache.py index 926222a..6781de8 100644 --- a/app/apps/cache.py +++ b/app/apps/cache.py @@ -184,7 +184,7 @@ async def get_cache_timestamp( ) -async def watch_app_status_changes() -> Result[None, Report]: +async def watch_app_status_changes(): """ Listens for app status changes on the custom Redis channel. This function implements the channel listener for app state changes. @@ -195,13 +195,12 @@ async def watch_app_status_changes() -> Result[None, Report]: logger.info("Starting app status channel listener") try: - listener = AppStatusUpdateListener() - await listener.connect() - # This will loop forever - await listener.listen() + while True: + listener = AppStatusUpdateListener() + await listener.connect() + # This will loop forever + await listener.listen() + logger.error("Recreating app status channel listener, as it stopped!") except Exception as e: return Err(Report(f"App status channel listener error: {e}", error=e)) - - logger.info("App status channel listener stopped") - return Ok(None) diff --git a/app/apps/tasks_impl/app_status_update.py b/app/apps/tasks_impl/app_status_update.py index 2ddec24..1d03cd9 100644 --- a/app/apps/tasks_impl/app_status_update.py +++ b/app/apps/tasks_impl/app_status_update.py @@ -60,6 +60,8 @@ async def update_app_state_task_impl( cache_ops = cache + logger.debug("update_app_state_task_impl: Starting task...") + redis_client = None try: redis_client = redis_from_url(redis_url, decode_responses=True) diff --git a/app/apps/tasks_impl/listeners.py b/app/apps/tasks_impl/listeners.py index 780288c..7a851b1 100644 --- a/app/apps/tasks_impl/listeners.py +++ b/app/apps/tasks_impl/listeners.py @@ -112,5 +112,5 @@ class AppStatusUpdateListener(BaseChannelListener): logger.trace("Broadcasting app management message") await broadcast_sse_msg(SSE.APP_STATE_MESSAGE, message.model_dump()) - if message.state == AppManagementProcessState.FINISHED: - await self.stop() + # Note: the app status listener will listen for the entire duration of the + # API running, so we don't need to stop it here diff --git a/app/main.py b/app/main.py index 39b53be..c14483f 100644 --- a/app/main.py +++ b/app/main.py @@ -372,7 +372,7 @@ async def warmup_new_connections(): _handle(id, SSE.LN_INFO, res[2]), _handle(id, SSE.LN_FEE_REVENUE, res[3]), _handle(id, SSE.WALLET_BALANCE, res[4]), - _handle(id, SSE.INSTALLED_APP_STATUS, res[5]), + _handle(id, SSE.APP_STATE_MESSAGE, res[5]), _handle(id, SSE.HARDWARE_INFO, res[6]), ] ) diff --git a/scripts/sync_to_blitz.sh b/scripts/sync_to_blitz.sh index 21999bb..9338cb2 100644 --- a/scripts/sync_to_blitz.sh +++ b/scripts/sync_to_blitz.sh @@ -72,7 +72,7 @@ fi # Needs sshpass installed echo "# syncing local code to: ${remote}" -sshpass -p "$passwordA" rsync -rvz --exclude .venv/ --exclude test_env_data/ --exclude .git/ -e "ssh -p ${sshPort}" $local $remote +sshpass -p "$passwordA" rsync -rvz --exclude .venv/ --exclude .env --exclude test_env_data/ --exclude .git/ -e "ssh -p ${sshPort}" $local $remote result=$? echo "result(${result})" if [ "$result" != "0" ]; then @@ -81,17 +81,21 @@ if [ "$result" != "0" ]; then exit 1 fi -# make sure uploaded/synced files belog again to the correct raspiblitz user to run +# make sure uploaded/synced files belong again to the correct raspiblitz user to run sshpass -p "$passwordA" ssh -p $sshPort admin@$localIP "sudo chown -R blitzapi:blitzapi ${remoteRepoPath}" # Restart the blitz service to activate changes -echo "# restarting blitzapi.service" +echo "# restarting service 'blitzapi.service'" sshpass -p "$passwordA" ssh -p $sshPort admin@$localIP 'sudo systemctl restart blitzapi.service' +echo "# restarting service 'blitzapi-celery-beat.service'" +sshpass -p "$passwordA" ssh -p $sshPort admin@$localIP 'sudo systemctl restart blitzapi-celery-beat.service' +echo "# restarting service 'blitzapi-celery-worker.service'" +sshpass -p "$passwordA" ssh -p $sshPort admin@$localIP 'sudo systemctl restart blitzapi-celery-worker.service' # Get latest logs entries echo "# latest log entries" -sshpass -p "$passwordA" ssh -p $sshPort admin@$localIP 'sudo journalctl -u blitzapi.service -n 10 --no-pager --no-hostname' +sshpass -p "$passwordA" ssh -p $sshPort admin@$localIP "sudo journalctl -u blitzapi-celery-worker.service -n 40 --no-pager --no-hostname" # Watch the logs echo "# watching logs - CTRL+C to exit" -sshpass -p "$passwordA" ssh -p $sshPort admin@$localIP 'sudo journalctl -u blitzapi.service -f --no-hostname' +sshpass -p "$passwordA" ssh -p $sshPort admin@$localIP "sudo journalctl -u 'blitzapi*' -f --no-hostname"