I have a bash script that launches wsgi for python and celery as well. The pythib project launes nicely though celery does not work. Below i incluse two ways of invoking the wsgi project and celery and none works as expected.
Way No1
...
echo "the PWD of project now is : ${PWD}"
exec gunicorn project.wsgi:application \
--name audit_tool \
--bind 0.0.0.0:8000 \
--timeout 1000 \
--workers 4 \
--log-level=$level \
--env DEBUG=${DEBUG} \
--log-config tmp.conf \
--preload &&
echo "Gunicorn started"
exec celery -A project worker -Q celery --loglevel=info --concurrency=1 --max-memory-per-child=25000 &&
sleep 2.5
ps aux | grep celery ;
echo 'done'
...
read -r -d '' cmd << end
gunicorn project.wsgi:application \
--name audit_tool \
--bind 0.0.0.0:8000 \
--timeout 1000 \
--workers 6 \
--log-level=$level \
--env DEBUG=${DEBUG} \
--log-config tmp.conf \
--preload
end
echo Starting Gunicorn.
($cmd)
read -r -d '' cmd2 << end
celery \
-A project \
worker \
-Q celery \
--loglevel=info \
--concurrency=1 \
--max-memory-per-child=25000
end
echo "Starting celery."
($cmd2)
Any help would be appreciated !!
I tried the two above ways and expectation was to launch the wsgi project and celery as well.
It depends how you want it to work...
If you want to do
thing1, wait till it finishes, thenthing2, use:If you want to do
thing1and at the same timething2, use:If
thing1is actually 2 things,thing1Aandthing1B, then you can combine them (Do not omit spaces ever. You may omit the semi-colons if the commands are spread across multiple lines):So, in answer to your question:
You can do it like this:
So that starts
gunicornand yourechocommand in the background, and while that is still running, it startscelery,sleepandpsas another group of commands running in parallel withgunicorn.