1
0
Fork 0
mirror of https://codeberg.org/Reuh/feather.git synced 2025-10-27 18:19:32 +00:00

feat: stop daemon on SIGTERM

This commit is contained in:
Étienne Fildadut 2025-10-09 19:50:41 +02:00
parent 0d0cd491ec
commit 07e0e0be9f
3 changed files with 10 additions and 4 deletions

View file

@ -26,7 +26,7 @@ After changing the configuration, you can call `feather regenerate` to regenerat
### Docker ### Docker
`podman run -d -v ./config.toml:/feather/config.toml -v ./data:/feather/data -v ./reader:/feather/reader --name feather feather daemon` `podman run -d -v ./config.toml:/feather/config.toml -v feather-data:/feather/data -v ./reader:/feather/reader --name feather feather daemon`
### Raw ### Raw
@ -52,3 +52,4 @@ After changing the configuration, you can call `feather regenerate` to regenerat
- [x] Command to force regenerate all HTML files (incl. recompute datetimes & paths) - [x] Command to force regenerate all HTML files (incl. recompute datetimes & paths)
- [x] Handle item updates - [x] Handle item updates
- [ ] Actually think about the issues created by the duplicate warning - [ ] Actually think about the issues created by the duplicate warning
- [ ] Set generated files creation/modification date instead of putting date in filename

View file

@ -34,7 +34,7 @@ template = '''
</head> </head>
<body style="background-color:black; color:white;"> <body style="background-color:black; color:white;">
<style>a{color:palevioletred; text-decoration:none;}</style> <style>a{color:palevioletred; text-decoration:none;}</style>
<article style="max-width:60rem; margin:auto;"> <article style="max-width:60rem; margin:auto; text-align:justify;">
<p style="display:flex; flex-direction:row; justify-content:space-between;"> <p style="display:flex; flex-direction:row; justify-content:space-between;">
<span>{{ published_formatted }}</span> <span>{{ published_formatted }}</span>
<span><a href="{{ origin_url }}">{{ origin_title }}</a></span> <span><a href="{{ origin_url }}">{{ origin_title }}</a></span>

View file

@ -8,6 +8,7 @@ import tomllib
import sys import sys
import argparse import argparse
import asyncio import asyncio
import signal
from datetime import datetime from datetime import datetime
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
from pathlib import Path from pathlib import Path
@ -276,8 +277,12 @@ async def daemon_sync_down_loop(config, client_session):
async def daemon(config, client_session): async def daemon(config, client_session):
print(f"Started in daemon mode; changes will be downloaded from the server every {config.daemon_sync_down_every}s and uploaded every {config.daemon_sync_up_every}s") print(f"Started in daemon mode; changes will be downloaded from the server every {config.daemon_sync_down_every}s and uploaded every {config.daemon_sync_up_every}s")
async with asyncio.TaskGroup() as tg: async with asyncio.TaskGroup() as tg:
tg.create_task(daemon_sync_up_loop(config, client_session)) tup = tg.create_task(daemon_sync_up_loop(config, client_session))
tg.create_task(daemon_sync_down_loop(config, client_session)) tdown = tg.create_task(daemon_sync_down_loop(config, client_session))
def cancel_tasks():
tup.cancel()
tdown.cancel()
asyncio.get_running_loop().add_signal_handler(signal.SIGTERM, cancel_tasks)
def regenerate_files(config): def regenerate_files(config):
for json_path in config.json_root.glob("*.json"): for json_path in config.json_root.glob("*.json"):