fix: don't stop app status listener

This commit is contained in:
fusion44 2025-04-14 15:37:19 +02:00 committed by fusion44
parent f1aa2107fd
commit bda5d565ee
5 changed files with 21 additions and 16 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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]),
]
)

View file

@ -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"