A deploy copies the new binary over the running one
Commoncp, scp or a build tool writes straight into the existing file while the service started from it is still running.
Confirm
fuser -v PATH 2>&1 || lsof PATH
A process running the file: access e in fuser, or FD txt in lsof
Fix
- Write to a temporary name in the same directory, then rename: cp new-app app.new && mv app.new app, then restart the service.
- Or use install -m 755 new-app app, which replaces the file the same way.
- Or stop the service, copy, and start it again, if a short gap is acceptable.