watchexec icon indicating copy to clipboard operation
watchexec copied to clipboard

watchexec fails to detect changes in file on the server

Open myugan opened this issue 1 year ago • 3 comments

Information:

  • Watchexec's version: 2.1.2
  • The OS you're using Ubuntu 22.04
  • The command: watchexec -q -w /etc/nginx/conf.d/*.template nginx -s reload

I'm using watchexec to monitor the base template of nginx in the Docker image I created. This setup ensures that any modifications trigger the generation of a new configuration and subsequently reload nginx. Locally, on my MacOS, this setup works perfectly with Docker Compose, using the following volume configuration:

volumes:
  - ./etc/conf.d/local/:/etc/nginx/conf.d/

However, when I deploy this setup on a server, where the code is pulled from a git repository, updates from the repository should modify the source code on the server. Despite this, watchexec seems unable to detect changes to /etc/nginx/conf.d/*.template, even when the contents are altered.

myugan avatar Aug 22 '24 08:08 myugan

uhh, can you paste the exact command you're using? what you've pasted shouldn't work at all, unless you've got a single .template file.

In any case, as described in the documentation, watch the folder and filter, don't watch individual files.

passcod avatar Aug 22 '24 10:08 passcod

I use the command watchexec -w /etc/nginx/conf.d/*.template. Is the wildcard causing the issue? My goal is to have my own custom script that reads /etc/nginx/conf.d/default.conf.template and generates the configuration file /etc/nginx/conf.d/default.conf in the end.

I am wondering if the command I used above is working for the local setup, but it is not producing the same result on the live server.

myugan avatar Aug 22 '24 11:08 myugan

Yes, the wildcard is interpreted by your shell, not by watchexec, so you'll end up with

watchexec -w /etc/nginx/conf.d/foo.template /etc/nginx/conf.d/bar.template

which will of course try to watch foo.template and run bar.template

passcod avatar Aug 22 '24 21:08 passcod