FileNotFoundError: [Errno 2] No such file or directory: 'auto-restart'

Viewed 489

Tried use watchdog to auto-restart celery worker/beat in docker container when code changed, and get error:

# 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'
#

all dependencies installed from requirements.txt:

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

When search 'auro-restart' file in container, got:

# 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
#

Anybody knows the reason of this issue?

2 Answers

Use this command instead

watchmedo auto-restart --patterns="*" --recursive -- celery -A main_app_name beat -l info

Related