diff --git a/Dockerfile b/Dockerfile index 088fa53..17a42a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,7 @@ WORKDIR /lanews RUN python3 -m venv venv && \ venv/bin/pip install -r requirements.txt +RUN mkdir database && \ + touch database/news.db + CMD ["venv/bin/python", "main.py"] \ No newline at end of file diff --git a/main.py b/main.py index 2c7659e..065f060 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,9 @@ import os import asyncio import json import time +import logging +logging.basicConfig(filename="lanews.log", level=logging.DEBUG) dotenv_path = join(dirname(__file__), '.env') load_dotenv(dotenv_path) @@ -16,7 +18,7 @@ loop = asyncio.get_event_loop() async def publish_news(): - print('Running web scrape...') + logging.debug('Running web scrape...') la_news = NewsScraper(loop=loop) articles = await la_news.news_articles() @@ -57,6 +59,6 @@ def run_async(coroutine): schedule.every().hour.do(run_async, publish_news) while True: - print('Checking schedule...') + logging.debug('Checking schedule...') schedule.run_pending() time.sleep(300) diff --git a/news.py b/news.py index dbf5816..09eee0b 100644 --- a/news.py +++ b/news.py @@ -24,7 +24,7 @@ class NewsScraper: raise Exception() self.client = client if None else ClientSession(loop=loop) - self.database = _create_connection('news.db') if database is None else database + self.database = _create_connection('database/news.db') if database is None else database self._md5 = hashlib.new('md5', usedforsecurity=False) async def _fetch_url(self, url):