aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile6
-rwxr-xr-xserve.py15
-rw-r--r--tagrss.py3
3 files changed, 17 insertions, 7 deletions
diff --git a/Dockerfile b/Dockerfile
index 61ce76f..80159e5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,10 +1,12 @@
-FROM python:3.11-bookworm
+FROM python:3.11-alpine
RUN mkdir /tagrss_data/
COPY . /tagrss
WORKDIR /tagrss
-RUN pip install -r requirements.txt
+RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8000
+STOPSIGNAL SIGINT
+
CMD ["./serve.py", "--host", "0.0.0.0", "--storage-path", "/tagrss_data/tagrss_data.db"]
diff --git a/serve.py b/serve.py
index 017ad78..c84efd6 100755
--- a/serve.py
+++ b/serve.py
@@ -20,7 +20,11 @@ import tagrss
MAX_PER_PAGE_ENTRIES = 1000
DEFAULT_PER_PAGE_ENTRIES = 50
-logging.basicConfig(level=logging.INFO)
+logging.basicConfig(
+ format='%(levelname)s:%(name)s:"%(asctime)s":%(message)s',
+ datefmt="%Y-%m-%d %H:%M:%S %z",
+ level=logging.INFO,
+)
parser = argparse.ArgumentParser()
parser.add_argument("--host", default="localhost")
@@ -149,16 +153,16 @@ def add_feed_effect():
parsed, epoch_downloaded = tagrss.fetch_parsed_feed(feed_source)
with core_lock:
try:
- core.add_feed(
+ feed_id = core.add_feed(
feed_source=feed_source,
parsed_feed=parsed,
epoch_downloaded=epoch_downloaded,
tags=tags,
)
+ logging.info(f"Added feed {feed_id} (source: {feed_source}).")
except tagrss.FeedAlreadyAddedError:
already_present = True
# TODO: handle FeedFetchError too
- logging.info(f"Added feed {feed_source} .")
return bottle.template(
"add_feed",
after_add=True,
@@ -196,6 +200,7 @@ def manage_feed_effect():
core.set_feed_source(feed["id"], feed["source"])
core.set_feed_title(feed["id"], feed["title"])
core.set_feed_tags(feed["id"], feed["tags"])
+ logging.info(f"Edited details of feed {feed['id']}.")
return bottle.template("manage_feed", feed=feed, after_update=True)
@@ -204,6 +209,7 @@ def delete_feed():
feed_id: int = int(bottle.request.forms["id"]) # type: ignore
with core_lock:
core.delete_feed(feed_id)
+ logging.info(f"Deleted feed {feed_id}.")
return bottle.template("delete_feed")
@@ -223,7 +229,7 @@ def update_feeds(run_event: threading.Event):
feeds = core.get_feeds(limit=limit, offset=limit * i)
for feed in feeds:
parsed_feed, epoch_downloaded = tagrss.fetch_parsed_feed(feed["source"])
- logging.debug(f"Updated feed with source {feed['source']} .")
+ logging.debug(f"Fetched feed {feed['id']} (source {feed['source']}).")
with core_lock:
core.store_feed_entries(feed["id"], parsed_feed, epoch_downloaded)
logging.info("Finished updating feeds.")
@@ -240,6 +246,7 @@ feed_update_run_event.set()
threading.Thread(target=update_feeds, args=(feed_update_run_event,)).start()
bottle.run(host=args.host, port=args.port, server="cheroot")
+logging.info("Exiting...")
feed_update_run_event.clear()
with core_lock:
core.close()
diff --git a/tagrss.py b/tagrss.py
index 6ac5270..e22c6b6 100644
--- a/tagrss.py
+++ b/tagrss.py
@@ -69,7 +69,7 @@ class TagRss:
parsed_feed: feedparser.FeedParserDict,
epoch_downloaded: int,
tags: list[str],
- ) -> None:
+ ) -> int:
with self.connection:
feed_title: str = parsed_feed.feed.get("title", "") # type: ignore
try:
@@ -87,6 +87,7 @@ class TagRss:
((feed_id, tag) for tag in tags),
)
self.store_feed_entries(feed_id, parsed_feed, epoch_downloaded)
+ return feed_id
def get_entries(
self,