无法启动 Celery 服务

无法启动 Celery 服务

我正在尝试在 Linux 上守护 Celery。在解决了很多错误并阅读了大量配置后,我无法运行 Celery。我正在运行 Ubuntu 20.04 和 Celery 5.2+。以下是我收到的错误:

● celery.service - Celery Service
     Loaded: loaded (/etc/systemd/system/celery.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2022-01-01 22:16:17 UTC; 22s ago
    Process: 15402 ExecStart=/usr/local/bin/pipenv run celery multi start ${CELERYD_NODES} -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD>
    Process: 15409 ExecStop=/usr/local/bin/pipenv run celery ${CELERY_BIN} multi stopwait ${CELERYD_NODES} --pidfile=${CELERYD_PID_FILE} (code=exited, status=2)

Jan 01 22:16:16 ip-172-31-37-240 pipenv[15409]:   warnings.warn(
Jan 01 22:16:16 ip-172-31-37-240 pipenv[15409]: /usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 0.23ubuntu1 is an invalid version and will not be supported>
Jan 01 22:16:16 ip-172-31-37-240 pipenv[15409]:   warnings.warn(
Jan 01 22:16:16 ip-172-31-37-240 pipenv[15409]: Loading .env environment variables...
Jan 01 22:16:17 ip-172-31-37-240 pipenv[15409]: Usage: celery [OPTIONS] COMMAND [ARGS]...
Jan 01 22:16:17 ip-172-31-37-240 pipenv[15409]: Try 'celery --help' for help.
Jan 01 22:16:17 ip-172-31-37-240 pipenv[15409]: Error: No such command '/usr/local/bin/celery'.
Jan 01 22:16:17 ip-172-31-37-240 systemd[1]: celery.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Jan 01 22:16:17 ip-172-31-37-240 systemd[1]: celery.service: Failed with result 'exit-code'.
Jan 01 22:16:17 ip-172-31-37-240 systemd[1]: Failed to start Celery Service.

我是一个终端菜鸟,但据我所知,当我cd /usr/local/bin/然后ls -a。我得到了以下文件结构。

.  ..  autopep8  celery  django-admin  gunicorn  markdown_py  pipenv  pipenv-resolver  pycodestyle  sqlformat  virtualenv  virtualenv-clone
#celery.service

[Unit]
Description=Celery Service
After=network.target

[Service]
Type=forking
User=celery
Group=celery

EnvironmentFile=/etc/default/celeryd
WorkingDirectory=/home/ubuntu/project/Instagram-Clone-Backend
ExecStart=/usr/local/bin/pipenv run celery multi start ${CELERYD_NODES} \
  -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
  --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}
ExecStop=/usr/local/bin/pipenv run celery ${CELERY_BIN} multi stopwait ${CELERYD_NODES} \
  --pidfile=${CELERYD_PID_FILE}
ExecReload=/usr/local/bin/pipenv run celery ${CELERY_BIN} multi restart ${CELERYD_NODES} \
  -A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE} \
  --logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}

[Install]
WantedBy=multi-user.target
#/etc/default/celeryd

 # Names of nodes to start
 #   most people will only start one node:
 CELERYD_NODES="worker1"
 #   but you can also start multiple and configure settings
 #   for each in CELERYD_OPTS
 #CELERYD_NODES="worker1 worker2 worker3"
 #   alternatively, you can specify the number of nodes to start:
 #CELERYD_NODES=10

 # Absolute or relative path to the 'celery' command:
 #CELERY_BIN="/usr/local/bin/celery"
 #CELERY_BIN="/virtualenvs/def/bin/celery"
 CELERY_BIN="/usr/local/bin/celery"

 # App instance to use
 # comment out this line if you don't use an app
 CELERY_APP="instagram.celery"
 # or fully qualified:
#  CELERY_APP="authentication.tasks:app"

 # Where to chdir at start.
 CELERYD_CHDIR="/home/ubuntu/project/Instagram-Clone-Backend"

 # Extra command-line arguments to the worker
 CELERYD_OPTS="--time-limit=300 --concurrency=8"
 # Configure node-specific settings by appending node name to arguments:
 #CELERYD_OPTS="--time-limit=300 -c 8 -c:worker2 4 -c:worker3 2 -Ofair:worker1"

 # Set logging level to DEBUG
 #CELERYD_LOG_LEVEL="DEBUG"

 # %n will be replaced with the first part of the nodename.
 CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
 CELERYD_PID_FILE="/var/run/celery/%n.pid"

 # Workers should run as an unprivileged user.
 #   You need to create this user manually (or you can choose
 #   a user/group combination that already exists (e.g., nobody).
 CELERYD_USER="celery"
 CELERYD_GROUP="celery"

 # If enabled pid and log directories will be created if missing,
 # and owned by the userid/group configured.
 CELERY_CREATE_DIRS=1

相关内容