{"action":"created","issue":{"url":"https://api.github.com/repos/celery/celery/issues/3459","repository_url":"https://api.github.com/repos/celery/celery","labels_url":"https://api.github.com/repos/celery/celery/issues/3459/labels{/name}","comments_url":"https://api.github.com/repos/celery/celery/issues/3459/comments","events_url":"https://api.github.com/repos/celery/celery/issues/3459/events","html_url":"https://github.com/celery/celery/issues/3459","id":178730430,"number":3459,"title":"celery multi is working strange with systemd","user":{"login":"gdubicki","id":566632,"avatar_url":"https://avatars.githubusercontent.com/u/566632?v=3","gravatar_id":"","url":"https://api.github.com/users/gdubicki","html_url":"https://github.com/gdubicki","followers_url":"https://api.github.com/users/gdubicki/followers","following_url":"https://api.github.com/users/gdubicki/following{/other_user}","gists_url":"https://api.github.com/users/gdubicki/gists{/gist_id}","starred_url":"https://api.github.com/users/gdubicki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gdubicki/subscriptions","organizations_url":"https://api.github.com/users/gdubicki/orgs","repos_url":"https://api.github.com/users/gdubicki/repos","events_url":"https://api.github.com/users/gdubicki/events{/privacy}","received_events_url":"https://api.github.com/users/gdubicki/received_events","type":"User","site_admin":false},"labels":[{"id":84246273,"url":"https://api.github.com/repos/celery/celery/labels/Category:%20Deployment","name":"Category: Deployment","color":"772123","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-22T21:52:50Z","updated_at":"2016-12-22T01:21:48Z","closed_at":null,"body":"Hi,\n\nAs I had problems with running celery using systemd on Centos 7 I did some testing to find out what exactly is happening. I used the \"tasks.py\" app from the tutorial (http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#application).\n\nHere are my findings.\n\n**1. You HAVE TO use PIDFile systemd service option for running a single worker**\n\nExample of a working service file with a single worker, but with 4 concurrent processes:\n\n```\n[Unit]\nDescription=Celery Service\nAfter=network.target\n\n[Service]\nType=forking\nUser=vagrant\nGroup=vagrant\n\n# directory with tasks.py\nWorkingDirectory=/home/vagrant/celery_example\n\n# this is REQUIRED!\n# you will still get a warning \"PID file /var/run/celery/single.pid not readable (yet?) after start.\" from systemd but service will in fact be starting, stopping and restarting properly\nPIDFile=/var/run/celery/single.pid\n\nExecStart=/home/vagrant/celery_example/venv/bin/celery multi start single-worker -A tasks --pidfile=/var/run/celery/single.pid --logfile=/var/log/celery/single.log \"-c 4 -Q celery -l INFO\"\n\nExecStop=/home/vagrant/celery_example/venv/bin/celery multi stopwait single-worker --pidfile=/var/run/celery/single.pid --logfile=/var/log/celery/single.log\n\nExecReload=/home/vagrant/celery_example/venv/bin/celery multi restart single-worker --pidfile=/var/run/celery/single.pid --logfile=/var/log/celery/single.log\n\n[Install]\nWantedBy=multi-user.target\n```\n\n**2. You CAN'T use `celery multi` --pidfile or --logfile options when running multiple workers**\n\nExample of a working service file with 3 workers, 4 concurrent processes each:\n\n```\n[Unit]\nDescription=Celery Service\nAfter=network.target\n\n[Service]\nType=forking\nUser=vagrant\nGroup=vagrant\n\n# directory with tasks.py\nWorkingDirectory=/home/vagrant/celery_example\n\n# don't set --pidfile or --logfile or it won't work!\nExecStart=/home/vagrant/celery_example/venv/bin/celery multi start 3 -A tasks \"-c 4 -Q celery -l INFO\"\n\nExecStop=/home/vagrant/celery_example/venv/bin/celery multi stopwait 3\n\nExecReload=/home/vagrant/celery_example/venv/bin/celery multi restart 3\n\n[Install]\nWantedBy=multi-user.target\n```\n\nWhen using pidfile or logfile only one worker is actually starting.\n\nCan you explain some of this?\n\nAlso I think that you should fix the example celery.service as it is not working - my celery was starting and stopping immediately when using it.\n"},"comment":{"url":"https://api.github.com/repos/celery/celery/issues/comments/268693716","html_url":"https://github.com/celery/celery/issues/3459#issuecomment-268693716","issue_url":"https://api.github.com/repos/celery/celery/issues/3459","id":268693716,"user":{"login":"chehsunliu","id":1827699,"avatar_url":"https://avatars.githubusercontent.com/u/1827699?v=3","gravatar_id":"","url":"https://api.github.com/users/chehsunliu","html_url":"https://github.com/chehsunliu","followers_url":"https://api.github.com/users/chehsunliu/followers","following_url":"https://api.github.com/users/chehsunliu/following{/other_user}","gists_url":"https://api.github.com/users/chehsunliu/gists{/gist_id}","starred_url":"https://api.github.com/users/chehsunliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chehsunliu/subscriptions","organizations_url":"https://api.github.com/users/chehsunliu/orgs","repos_url":"https://api.github.com/users/chehsunliu/repos","events_url":"https://api.github.com/users/chehsunliu/events{/privacy}","received_events_url":"https://api.github.com/users/chehsunliu/received_events","type":"User","site_admin":false},"created_at":"2016-12-22T01:21:48Z","updated_at":"2016-12-22T01:21:48Z","body":"Yes, this workaround is very bad... For my service, I use `celery worker` instead of `celery multi start` in the systemd script to avoid this issue. I guess single parent PID is much easier for systemd to capture."}}
{"actor":{"display_login":"chehsunliu"}}