Use the Windows Azure production agent role with celery

I have a web role in Windows Azure that runs Django. I have a time-consuming calculation for asynchronous startup, and an example of use is as follows: the client sends a request for calculation, the server returns an identifier to check the result of the calculation, and then the client can use this identifier to retrieve this result as soon as it disappears.

Now I am missing the background, and I would like to use the role of the working role in Windows Azure for this. Since I want to stay independent of Azure, I would like to use Celery to handle this part. The disadvantage is that I could not find any resource dedicated to this topic. Does anyone have any idea?

Thank you very much in advance!

+4
source share
2 answers

I did a solid webjob in azure, which works with celery.

<your repo>/App_Data/jobs/continuous/Celery/celery.cmd

At celery.cmd, I start celery like this.

set PYTHONPATH=%PYTHONPATH%;D:\home\site\wwwroot\site-packages\
cd D:\home\site\wwwroot\src
DEL D:\home\site\wwwroot\src\celery.pid
D:\Python34\python.exe -m celery -A conf worker -Q celery -c 10 -l DEBUG --pidfile D:\home\site\wwwroot\src\celery.pid

So what is happening here is that I set the python path (I'm sure it can be done globally in azure), then I just connected to the django root of the project and deleted any PID file before starting the celery command line style, When this process ends, the celery will restart again, because it is a continuous webjob.

You might want to customize the flags to suit your needs.

If you need celery to work on only one machine. You should have a file <your repo>/App_Data/jobs/continuous/Celery/settings.job:

{"is_singleton": true}
+4
source

, , , -:  1. celery.cmd :

cd D:\home\site\wwwroot 
D:\home\site\wwwroot\env\Scripts\python.exe -m celery -A yourapp.celery worker --loglevel=info --concurrency=1

2. settings.job ( , - , ):

{"is_singleton": true}

3. 2

4. Azure - zip .

0

Source: https://habr.com/ru/post/1525470/


All Articles