periodiq -v my.broker.module documentation
Could you please elaborate how to run the scheduler? I'm a bit confused about the my
and module
part, where comes from?
Can you give me some snippets related to how the file & folder structure should look like?
In my current scenario I have:
[root-folder]/app.py
[root-folder]/requirements.txt
[root-folder]/entrypoint.sh
[root-folder]/image.jpg
and running this via Docker
, using the following config:
FROM python:3
WORKDIR /usr/src/app
ADD ["./entrypoint.sh", "./requirements.txt", "./app.py", "./image.jpg", "./"]
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install -U 'dramatiq[rabbitmq, watch]'
ENV HOME /root
RUN chmod a+x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
entrypoint.sh
looks like:
#!/bin/bash
periodiq -v app.broker.app
app.py
looks like:
import dramatiq, requests, cv2, time, os
from dramatiq.brokers.stub import StubBroker
from periodiq import cron, PeriodiqMiddleware
import logging
from datetime import datetime
broker = StubBroker()
broker.add_middleware(PeriodiqMiddleware())
dramatiq.set_broker(broker)
logger = logging.getLogger(__name__)
@dramatiq.actor(periodic=cron('* * * * *'))
def everyMinuteFunction():
print("everyMinuteFunction")
if __name__ == "__main__":
everyMinuteFunction()
Lastly the requirements.txt
has the following content:
pika
requests
numpy
dramatiq
periodiq
Edited by El Severo