Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 1.31 KB

deferredFileOperations.md

File metadata and controls

20 lines (14 loc) · 1.31 KB

Deferred file operations

To support self updating services, winsw offers a mechanism to perform file operations before the process you specified in the configuration file gets launched. This is often necessary because Windows prevents files from overwritten while it's in use.

To perform file operations, write a text file (in the UTF-8 encoding) at myapp.copies (that is, it's in the same directory as myapp.xml and myapp.exe but with a different file extension), and for each operation add one line:

  • To move a file, write a line src>dst. If the dst file already exists it will be overwritten.

The success or failure of these operations will be recorded in the event log.

Note that it is apparently possible to rename executables even when it's running, which makes sense if you think about file handles. Kohsuke has failed to find any authoritative source of information about this, but experimentally this even works on Windows XP and presumably on all the later Windows versions. This behavior can be used to update winsw.exe itself. Also see WINSW_EXECUTABLE environment variable.

The <download> element in the configuration file also provides an useful building block for a self updating services.