Celery.service启动失败:USER步骤报错无对应进程问题排查
First, let's recap the error you're seeing from journalctl -f:
Mar 21 19:14:25 ubuntu-2gb-nyc3-01 systemd[21431]: celery.service: Failed at step USER spawning /home/mike/movingcollage/movingcollageenv/bin/celery: No such process
This error usually boils down to issues with the user specified in your systemd service file, or problems with the Celery executable's path/permissions. Let's walk through troubleshooting and fixing it step by step:
Verify the user in your celery.service file exists
Open your celery.service configuration file (typically at/etc/systemd/system/celery.serviceor~/.config/systemd/user/celery.service) and check theUser=line (e.g.,User=mike). Run this command to confirm the user exists on your system:id mikeIf the user doesn't exist, create them with:
useradd -m mikeCheck if the Celery executable path is valid and accessible
The error points to/home/mike/movingcollage/movingcollageenv/bin/celery—first confirm this file actually exists:ls -l /home/mike/movingcollage/movingcollageenv/bin/celeryIf it's missing, your virtual environment might be corrupted. Recreate it and reinstall Celery:
# Remove the old environment if needed rm -rf /home/mike/movingcollage/movingcollageenv # Create a new virtual environment python3 -m venv /home/mike/movingcollage/movingcollageenv # Activate it and install Celery source /home/mike/movingcollage/movingcollageenv/bin/activate pip install celeryAlso, make sure the
mikeuser has execute permissions on the Celery binary and can access all parent directories:chmod +x /home/mike/movingcollage/movingcollageenv/bin/celery chmod 755 /home/mike /home/mike/movingcollage /home/mike/movingcollage/movingcollageenvTweak your systemd service file configuration
Ensure your celery.service file includes the correct user, group, and working directory. A minimal valid config might look like this:[Unit] Description=celery service After=network.target [Service] User=mike Group=mike WorkingDirectory=/home/mike/movingcollage ExecStart=/home/mike/movingcollage/movingcollageenv/bin/celery -A your_project_name worker --loglevel=info [Install] WantedBy=multi-user.targetReplace
your_project_namewith your actual Celery app name.Reload systemd and restart the service
After making any changes to the service file, reload systemd to pick up updates, then restart Celery:systemctl daemon-reload systemctl restart celery.serviceCheck the logs again with
journalctl -u celery.service -fto confirm the error is resolved.
内容的提问来源于stack exchange,提问作者Michael

