Reputation: 9769
I'm stuck with running celery 3.1.17 on windows 7 (and later on 2013 server) using redis as backend.
In my celery.py
file I defined an app with one scheudled task
app = Celery('myapp',
backend='redis://localhost',
broker='redis://localhost',
include=['tasks']
)
app.conf.update(
CELERYBEAT_SCHEDULE = {
'dumdum': {
'task': 'tasks.dumdum',
'schedule': timedelta(seconds=5),
}
}
)
The task is writing a line to a file
@app.task
def dumdum():
with open('c:/src/dumdum.txt','w') as f:
f.write('dumdum actually ran !')
Running the beat service from the command line
(venv) celery beat -A tasks
celery beat v3.1.17 (Cipater) is starting.
__ - ... __ - _
Configuration ->
. broker -> redis://localhost:6379/1
. loader -> celery.loaders.app.AppLoader
. scheduler -> celery.beat.PersistentScheduler
. db -> celerybeat-schedule
. logfile -> [stderr]@%INFO
. maxinterval -> now (0s)
[2015-03-15 10:50:33,265: INFO/MainProcess] beat: Starting...
[2015-03-15 10:50:35,496: INFO/MainProcess] Scheduler: Sending due task dumdum (tasks.dumdum)
[2015-03-15 10:50:40,513: INFO/MainProcess] Scheduler: Sending due task dumdum (tasks.dumdum)
Looks promising, BUT NOTHING HAPPENS. Nothing is being writen to the file.
The celery documentation on runnig beat on windows reference this article from 2011. The article explains how to run celeryd
as a scheduler task on windows. celeryd
has been deprecated since and the command stated in the article is no longer working (there is no celery.bin.celeryd
module).
So, What is the solution here ?
Thanks.
Upvotes: 2
Views: 6930
Reputation: 39
Run
Server:
python manage.py runserver
Celery:
celery -A my_new_manager worker -l info -P gevent
Celery beat:
celery -A [project-name] beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
And celery beat will work, the main question is how us, the windows users DEPLOY it. Still working for it
Upvotes: 0
Reputation: 584
Celery beat and celery worker can not run with same project, as celery v4.0 stop supporting win for celery worker and celery beat. one thing you can do, suppose your project name is a recommendation_system and your project hierarchy is as below:
recommendation_system
--your_app_dir
--main.py #or manage.py
--app.py
and you define scheduler(for beat) and worker fun in main.py, then you have to make a copy of this project let's say named recommendation_system_beat. now to run workers you need to go to inside the recommendation_system directory then run cmd as :
python.exe -m celery -A main worker --pool=solo --concurrency=5 --loglevel=info -n main.%h --queues=recommendation
where the recommendation parameter is the queue name. set concurrency no according to your need.
this will run your workers. but beat will not run, to run beat
now got to recommendation_system_beat and run the following cmd:
python.exe -m celery -A main beat --loglevel=info
this will run all you beat (scheduler)
so ultimately you need to run worker and beat in two different repo
Upvotes: 0
Reputation: 2288
I used following command to run celery beat on windows:
python manage.py celery beat
after following these steps for installation:
it worked for me perfectly fine!
Upvotes: 3