1

尝试在代码更改时使用看门狗自动重启 docker 容器中的 celery worker/beat,并得到错误:

# watchmedo auto-restart -d . -R -- celery -A main_app_name beat -l info
Traceback (most recent call last):
  File "/usr/local/bin/watchmedo", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/watchdog/watchmedo.py", line 641, in main
    args.func(args)
  File "/usr/local/lib/python3.9/site-packages/watchdog/watchmedo.py", line 625, in auto_restart
    handler.start()
  File "/usr/local/lib/python3.9/site-packages/watchdog/tricks/__init__.py", line 174, in start
    self.process = subprocess.Popen(self.command, preexec_fn=getattr(os, 'setsid', None))
  File "/usr/local/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'auto-restart'
#

从 requirements.txt 安装的所有依赖项:

***
pyyaml~=6.0
watchdog~=2.1.6
auto-restart~=2.2
***

在容器中搜索“auro-restart”文件时,得到:

# find / -type f -name '*auto*restart*'
/root/.cache/pip/wheels/40/11/c1/9e570f5aac7910cf701243cda8b5fc58e56b329a3d73b4840b/auto_restart-2.2-py3-none-any.whl
/usr/local/bin/auto_restart
/usr/local/bin/auto_restart_tool
/usr/local/lib/python3.9/site-packages/auto_restart/auto_restart_when_git_changed.py
/usr/local/lib/python3.9/site-packages/auto_restart/__pycache__/auto_restart_when_git_changed.cpython-39.pyc
#

有人知道这个问题的原因吗?

4

1 回答 1

1

恢复到 2.1.5 解决了这个问题。

https://github.com/gorakhargosh/watchdog/issues/855

于 2021-11-17T12:01:13.380 回答