Welcome to the forums. Hope you enjoy your stay here in the land of Zig.
--watch needs the watched build step to finish.
The run step doesn’t finish before your program exits, so it never gets there. If you interrupt the process to close the server (ctrl-c), then the zig process gets killed as well, so --watch doesn’t trigger.
That is to say, your server executable needs to cooperate and exit cleanly when you update the source code.
Maybe write a small shim that launches the server in a thread and then looks for filesystem changes in the source files with (your OS’s equivalent of) inotifywait?
Its not possible yet, once a run command runs, the compiler cant stop it. But zig build will get an api in the future that can restart a rebuilt running process
EDIT: Just for completeness, both tools were mentioned in a previous thread. The difference is that now we can have the build system do the rebuilds on its own, potentially with -fincremental, and now we only watch the outputs with external tool.