Skip to content

wsw 0.10.0

Latest

Choose a tag to compare

@github-actions github-actions released this 07 Oct 19:46
· 8 commits to main since this release
4d2505f

wsw 0.10.0 adds what real-world services need: a graceful stop, restart policies, environment variables, dependencies, any service account and a configuration file. It is still a single static executable, and one command line still installs a service.

wsw install --name Redmine --exe C:\Redmine\ruby\bin\ruby.exe --working-dir C:\Redmine\redmine `
  --env RAILS_ENV=production --env "PATH=C:\Redmine\ruby\bin;%PATH%" `
  --depends-on RedminePostgreSQL --start-type delayed-auto `
  --account-name "NT AUTHORITY\NetworkService" --grant-dir C:\Redmine\redmine `
  --restart on-failure --restart-delay 10 --stop-timeout 20 `
  --log-dir C:\Redmine\logs --log-max-size 10 --max-log-files 8 `
  -- C:\Redmine\ruby\bin\bundle exec puma -e production -b tcp://0.0.0.0:3000

New features

  • Direct start: --exe <path> -- <args...> starts the executable without cmd.exe, so there are no cmd.exe quoting rules to deal with and the real exit code is reported. --cmd is still supported.
  • Graceful stop: on stop and on system shutdown, the process receives Ctrl+C (or --stop-cmd is run instead). wsw waits up to --stop-timeout seconds (default 15) before killing the process tree.
  • Restart policies:
    • --restart always|on-failure|never;
    • --restart-delay, with exponential backoff up to --restart-max-delay;
    • --reset-after and --max-restarts;
    • native SCM recovery actions with --scm-failure-actions and --scm-failure-reset.
  • Environment: --env KEY=VALUE and --env-file. %VAR% references are expanded when the service starts.
  • Service settings:
    • --depends-on;
    • --start-type auto|delayed-auto|manual|disabled;
    • --display-name and --description.
  • Accounts: LocalSystem, LocalService, NetworkService, virtual accounts (NT SERVICE\name) and gMSA (DOMAIN\name$) need no password. --grant-logon-right grants the "Log on as a service" right, and --grant-dir grants write access to a directory.
  • Logs:
    • --log-dir;
    • size based rotation with --log-max-size;
    • stderr in a separate file with --log-split (wsw logs --stderr).
  • Hooks: --pre-start, --post-stop and --hook-timeout.
  • Configuration file: wsw install --config service.toml reads the options from a TOML file whose keys are named like the flags.
  • Management: wsw update changes an installed service without reinstalling it. A failed update restores the previous configuration. wsw status --verbose shows the effective configuration.

The README has a table that maps every WinSW XML element to the matching wsw option.

Fixes

  • The SCM is now told about the real state of the service (StartPending, Running, StopPending with checkpoints) and about its real exit code, so Windows recovery actions can kick in.
  • A process that keeps crashing is restarted with backoff instead of every second.
  • The output of the process is now logged line by line: lines and UTF-8 characters split across two reads are no longer garbled.
  • Child processes can no longer escape the Job Object, so the whole process tree is stopped together with the service.
  • Every command exits with a non-zero code when it fails, and restart also starts a service that was stopped.

Upgrading from 0.9.x

  • Services installed by 0.9.x keep running after the binary is replaced, and every 0.9.x command line still works.
  • wsw update --name <service> migrates an old service to the new configuration storage, which lives in the registry under the service key.
  • Behaviour changes:
    • On stop the process first receives Ctrl+C. A process that ignores it is killed after 15 seconds instead of immediately.
    • Restarts after a crash slow down progressively, up to one every 60 seconds.
    • wsw run in a terminal now supervises the process exactly like the service does, until you press Ctrl+C.