- edited description
Add Flower to install and link to manage Celery tasks
Refs #662 which sorted out RabbitMQ, but we need to monitor Celery too.
Either just install and link to same host on port 5555, or make use of the API to display in OpenREM as we do with RabbitMQ: https://flower.readthedocs.io/en/latest/api.html
Need to add as systemd daemon, eg
[Unit] Description=Flower Celery Service [Service] User=your_user Group=www-data WorkingDirectory=/var/www/project-working-directory ExecStart=/home/user/miniconda3/envs/virtualenv/bin/flower --port=5555 --loglevel=info -A yourproject Restart=on-failure Type=simple [Install] WantedBy=multi-user.target
A command equivalent to celery -A openremproject flower --address=127.0.0.1
would mean that it could be used with the API from OpenREM without being accessible password-free from other computers.
Comments (85)
-
reporter -
Looks good, but does it work in Windows? I'll take a look.
-
reporter Thanks. The only thing that would be different should be the daemonisation of flower.
-
reporter Also need to not suggest that RabbitMQ queues that are waiting for a result to be returned can be purged, because they can't!
-
reporter Only show purge button if tasks are waiting in ready state, not unacknowledged. Refs
#705[skip ci] not covered→ <<cset 2cc68b3649d9>>
-
reporter Initial stab at Flower interface. Abort doesn't currently work as 'results backend is not configured'. Refs
#705→ <<cset 1f71b91c734c>>
-
reporter Tasks are now terminatable! Refs
#705→ <<cset e3ed5635c760>>
-
reporter Moving the return statement. Refs
#705[skip ci] as code not tested.→ <<cset 6143088a35ec>>
-
Can I suggest something like the following command to run flower? We can make it clear that the user can specify the port and log file name / location.
celery -A openremproject flower --port=5555 --loglevel=info --log-file-prefix=MEDIA_ROOT\celery\flower.log
-
The Windows batch file that I use to run / restart celery kills all processes with the name "celery". This will kill flower as well. I've re-worked the batch file so that it uses the pid of the celery worker process to kill the correct celery. See below. I've also created a flower batch file that can be used to run flower as a service on Windows (this isn't capable of restarting Flower - it can just be used to start it up).
Batch file for starting / restarting celery:
ECHO OFF :: Create variables containing the path to OpenREM and the name and path of the :: celery pid and log files SET openremPath=D:\Server_Apps\python27\Lib\site-packages\openrem SET celeryPidFile=E:\media_root\celery\default.pid SET celeryLogFile=E:\media_root\celery\default.log :: Change to the drive on which OpenREM is installed and navigate to the :: OpenREM folder D: CD %openremPath% :: Attempt to shutdown celery gracefully celery -A openremproject control shutdown --timeout=10 :: Pause this file for 10 s to ensure that the above has time to work (you may :: need to check that the 'timeout' command is available on your Windows :: system. Some systems may have 'sleep' instead, in which case replace the :: line below with: :: SLEEP 10 TIMEOUT /T 10 :: Kill any remaining celery tasks (ungraceful) and delete the pid file in case :: the above graceful shutdown did not work :: Read the celery PID in from from the default.pid file IF EXIST %celeryPidFile% ( :: Read the pid values in from the file SET /P CeleryPid=<%celeryPidFile% :: Kill the process with that pid value TASKKILL /F /PID %celeryPid% :: Force the deletion of the pid file DEL /F %celeryPidFile% ) :: Restart a new instance of celery ::celery worker -n default -P solo -Ofair -A openremproject -c 4 -Q default --pidfile=e:\media_root\celery\default.pid --logfile=e:\media_root\celery\default.log :: Changing concurrency to 1 to see if it stops the kombu messages in default.log about "Couldn't ack" - https://stackoverflow.com/questions/35325207/celery-and-rabbitmq-timeouts-and-connection-resets celery worker -n default -P solo -Ofair -A openremproject -c 1 -Q default --pidfile=%celeryPidFile% --logfile=%celeryLogFile%
Batch file for starting flower:
ECHO OFF :: Create variables containing the path to OpenREM and the name and path of the :: celery pid and log files SET openremPath=D:\Server_Apps\python27\Lib\site-packages\openrem SET flowerLogFile=E:\media_root\celery\flower.log SET flowerPort=5555 :: Change to the drive on which OpenREM is installed and navigate to the :: OpenREM folder D: CD %openremPath% :: Run flower celery -A openremproject flower --port=%flowerPort% --loglevel=info --log-file-prefix=%flowerLogFile%
-
I now have flower running on my live Windows installation. I'm going to see whether it works OK when run using the two batch files I've posted above.
-
reporter Modified main revoke functions to modern Celery method, which has the advantage of removing red error warnings! Also some tidying up and a 'reverse' that was left in views.py after it had been removed from the imports. Refs
#705→ <<cset d7335e521f40>>
-
reporter Terminate Celery task now deletes job from database too. Refs
#705→ <<cset 745fa7713cd9>>
-
reporter Changed RabbitMQ table around, added link to Celery, added rudimentary text to Celery and connection error template. All needs linking to appropriate docs. Refs
#705→ <<cset 4f564b0a298e>>
-
reporter @dplatten / anyone else who fancies it, would you try this branch (issue705flower, Diff to develop )
As long as you have flower installed and running, it should work. Needs fine tuning, tidying up and docs, but it would be good to see if it reliably shows and controls the queues and tasks on different setups.
-
@edmcdonagh I'll give this a go, but it will be easiest for me to test properly if I install it on my live system. Is the beta behaving on your system?
-
reporter I'll roll a beta three
-
reporter And if the question was referring to beta 2 on my production system, apart from the DX exports, yes 😁
-
Thanks Ed - a beta release that incorporates this branch would be easiest for me to use.
Yes, I was referring to the beta 2 on your production system. Glad to hear it's working OK.
I'm looking forward to having the fluoroscopy high dose alerts available on our live system.
-
reporter Added rabbitMQ queue deletion, some docs/stubs. Refs
#705→ <<cset 0014d1395f9c>>
-
reporter Fixing setup missing comma. Refs
#705→ <<cset 058da5b8af68>>
-
reporter Added a start-flower placeholder into upgrade instructions. Refs
#705[skip ci] docs only→ <<cset 48a6455ea7f8>>
-
reporter Merged in issue705flower (pull request #261)
Refs
#705Not complete, particularly docs.
→ <<cset 231566a551a1>>
-
reporter Beta three is available: https://docs.openrem.org/en/0.9.0b3/release-0.9.0.html
I have upgraded my production system... see how it goes over the next few days.
-
reporter Adding Windows version of Celery pidbox queue to html intro text. Refs
#705[skip ci] html text only→ <<cset a75ee3fbc43b>>
-
Beta 3 is running on my live system. All seems to be OK so far. It's good to see celery jobs in the OpenREM interface - I have entries for skin dose map items, DICOM queries, exports etc.
-
reporter Added netdicom and make_skin_map to recognised tasks to delete the job from the database. Refs
#705→ <<cset 20a9561f79ff>>
-
reporter Attempt at systemd control of flower. Refs
#705→ <<cset 674390f928a7>>
-
reporter Flower log prefix actually needs to be the name of the file. Adding missing quote mark. Refs
#705→ <<cset 4993c7c00436>>
-
reporter Link Ubuntu one-page into release notes. Refs
#705→ <<cset 87a7b55a99e0>>
-
reporter Corrected missing quote (another one). Rearranged ExecStart line to fit. Refs
#705[skip ci] docs only (whoops, just remembered)→ <<cset f94bff8ff3f1>>
-
reporter Made Flower port configurable. Added start services instructions. Refs
#705[skip ci] docs or non-tested only→ <<cset 5d44dfcdd969>>
-
reporter Added option to drop address to allow wider use. Attempt to make Celery Windows warning nicer. Refs
#705[skip ci] docs or non-tested only→ <<cset 6ec969a15ea9>>
-
Altered wording at the top of the Celery and RabbitMQ admin pages. Ed, please revert back if you're not happy with this. References issue
#705→ <<cset 59759d4461ae>>
-
reporter Updated celery-linux deamonising docs to reflect one-page Ubuntu docs for Celery and Flower. Linked from start services. Refs
#705[skip ci] docs @dplatten - can you update the Windows docs please (celery-windows.rst)→ <<cset e230ecaf7fbd>>
-
reporter Correcting grammar and mistakes. Now using this config on my system. Refs
#705[skip ci] docs→ <<cset 96c20af65d12>>
-
Updating Windows instructions for setting up Celery and Flower as a . Need to check that I have used the correct line numbers in the text describing the batch files. References issue
#705→ <<cset 5ec231d24996>>
-
Updating Windows instructions for setting up Celery and Flower as a [skip ci]. References issue
#705→ <<cset b2bfb951bf71>>
-
reporter Added in changing port for both Windows and Linux Flower daemonisation. @dplatten, feel free to modify. Refs
#705[skip ci] docs→ <<cset 96a8cc838978>>
-
reporter Removing accidental indent Refs
#705[skip ci] docs→ <<cset a72a51fa7299>>
-
Updating Windows celery doc - noticed a strange block of text [skip ci]. References issue
#705→ <<cset 655f61b58f92>>
-
reporter Revising to feed current and complete tasks separately to page, before laptop died! New branch as this is not a working setup. Refs
#705[skip ci] docs→ <<cset d71a295b68bd>>
-
I've been having trouble with queries. I think this typo may have been the route cause, preventing the previous Celery from being killed. Corrected typo in windows Celery documentation [skip ci]. References issue
#705→ <<cset 42f0f697e25a>>
-
My Windows batch file that shuts down Celery and then restarts it doesn't work. The pid stored in default.pid is the process code associated with python.exe that is running Celery. Killing this pid stops python.exe, but does not stop celery.exe.
-
reporter Oops!
-
I may have to redesign the batch file to kill all processes with the name celery.exe. This will also kill Flower, so the file will have to restart Flower as well as Celery.
What's slightly odd is that when I try the graceful shutdown from the command line it always seems to work.
-
reporter That would be annoying as by default you'd lose all the jobs each time and flower would be empty.
There is a persistent flag or similar though that would be worth ticking. Unless you only care about the right now jobs. Not sure.
Flower might of course point out that with your aggressive restart regeme that tasks are being revoked? It maybe not
-
I have an updated batch file running on my live system. I'll report back tomorrow morning on how it has got on. The system is scheduled to carry out several PACS queries between now and then.
-
I may add the persistent flag to my Flower command (https://flower.readthedocs.io/en/latest/config.html#persistent)
-
reporter Basically works. No column sorting currently. Refs
#705[skip ci] docs→ <<cset 7f2cca696b17>>
-
reporter Modified so no longer concertina - each panel independent, older starts closed. Reset recent to 6 hours. Refs
#705[skip ci] docs→ <<cset d312df9dae5c>>
-
reporter Broken up the rabbitMQ queues. Not tested. Refs
#705[skip ci] docs→ <<cset b10c9ea01460>>
-
I have re-written the Windows batch files used to start up Celery and Flower, and restart them if required. The original ones further up this issue didn't work correctly because executing a celery command stops execution of the file until the celery command has finished... which it never should. Celery and Flower need to be run from the batch file using their own batch file. I have done this for my live system and need to put them on here and in the official documentation.
-
reporter Much improved RabbitMQ display. I think. Refs
#705[skip ci] docs→ <<cset 662abeefb459>>
-
reporter PyCharm code reformat. Refs
#705[skip ci] docs→ <<cset 6fd0561c165f>>
-
reporter Getting recent and older columns to line up. Refs
#705[skip ci] docs→ <<cset 9a0fab347100>>
-
reporter Flower status now working as intended. Refs
#705[skip ci] docs→ <<cset 73db5b4585bc>>
-
Updated the example Windows batch files to correct an error in the TASKKILL command and also address a problem with my original Flower version where the batch file waited for each celery task to complete before moving to the next command. These pauses meant that if the batch file started Flower then it never got to the line to restart Celery (the erroneous version was never available in release documentation, so shouldn't affect any users except me). This new version starts a separate background batch file to run the celery or flower commands. These files are in-use on my live system and are working well [skip ci]. References issue
#705→ <<cset e602708e4022>>
-
reporter Great. Do you mind if I merge my issu705flower-reorg branch back into this one, with the intention of merging this into develop for the next beta? It means losing some of the sorting javascript you worked on, hence my hesitation... See Pull Request #266
-
reporter Merged in issu705flower-reorg (pull request #266)
Refs issue
#705Improves display of queues, at the expense (for now) of sortable columns.
→ <<cset 960f46338da9>>
-
Making it possible to sort those tables made my head hurt, but I think we should be able to re-instate the code for the new version.
-
reporter I knew it had been troublesome, hence my hesitation! The code is mostly all there, but a lot of it commented out. It all went wrong when I changed from one list to three, which on the RabbitMQ page has gone back to one, which is still sorted. I don't think there is any sorting now on the Flower page.
-
reporter -
reporter I have 0.9.0b5 installed on my production system now - I'll see how it goes.
-
Perhaps a little picky, but I think that the celery status page (http://dev.openrem.org/openrem/admin/celery/) would look better if the "Active tasks" section was formatted in the same way as the "Recent Tasks" and "Older tasks" section
-
reporter Very happy for it to be restyled - bearing in mind the active tasks has an extra column.
What do you think about the concept of active, recent and older?
Any thoughts on the RabbitMQ layout?
-
I really like the active, recent and older tables on the Celery page. I've not thought about the RabbitMQ page yet.
I'll put the Celery active table in the same format as the others and fix the table sorting at some point over the weekend.
-
reporter Thanks!
-
reporter Happy Christmas!
-
Changed Celery active task table to match the other two. References issue
#705→ <<cset a189bcad2082>>
-
Scrap the above commit - I needed to create a new branch, which I've now done.
-
Changed Celery active task table to match the other two. References issue
#705→ <<cset 715c141357f9>>
-
Should the Flower queues be visible on the Celery admin page somewhere? They're not for me.
-
reporter Do you mean the ev ones? On the RabbitMQ page?
In which case no, I've suppressed them, as they don't tell you anything useful.
Instead there is a call to Flower which feeds the status on the RabbitMQ page.
-
It's unlikely I'm going to be able to add the sorting to the new celery tables this week. I've also managed to make the new pages throw some errors when testing. I'll try and reproduce reliably and post here at some point.
-
Celery tables can now be sorted. The time-related columns do not sort correctly at the moment - need to add a custom sort key. References issue
#705.→ <<cset de1e828a0397>>
-
Time-related columns in Celery table now sort correctly. References issue
#705→ <<cset ca259cdb80fd>>
-
Reformatted the RabbitMQ page to match the Celery page. The panels on the RabbitMQ page can't be closed and stay shut as the whole section of HTML, including the panel code, is replaced every two seconds. References issue
#705→ <<cset 033ddff10044>>
-
Changed div class for Celery and Rabbit table sections to make them bolder. Changes to style only, so [skip ci]. References issue
#705→ <<cset 8ef46619fff9>>
-
reporter Moved statuses and jobs waiting to celery page. Need to add terminate RabbitMQ queued jobs, then can remove RabbitMQ page. Refs
#637,#662,#705[skip ci]→ <<cset 4099a54b8476>>
-
reporter Added button to purge RabbitMQ queue. Refs
#637,#662,#705[skip ci]→ <<cset 81e397a23070>>
-
reporter Removed RabbitMQ url, views, templates. Refs
#637,#662,#705[skip ci]→ <<cset 2ddd46f902e4>>
-
reporter New titles, links to docs, removed non-useful text. Refs
#637,#662,#705[skip ci]→ <<cset 12d64f7dfa6d>>
-
reporter Adding refs
#349,#705,#723to changes. [skip ci]→ <<cset f4d7081dc6c5>>
-
reporter - changed status to resolved
Merged in issue349celery (pull request #277)
RabbitMQ, Celery and Flower task management changes
Fixes
#349,#705,#723, refs#637,#662Approved-by: Luuk Approved-by: David Platten
→ <<cset f4bb4875a6fc>>
- Log in to comment