This cookbook provides a custom Chef resource which configures Windows services using WinSW.
If using Berkshelf, add a dependency to this repo:
cookbook 'winsw', git: 'https://github.com/github1/winsw-cookbook'
A basic winsw resource can be configured as follows:
winsw 'my_winsw_service' do
  executable 'java'
  args %w(-jar C:\\SomeService.jar)
endThe resource properties generally correspond with configuration options defined in the WinSW XML configuration file described here.
An array of arguments to pass to the executable.
The directory to write the service configuration to. Defaults to :file_cache_path.
If set to false, the service will be installed but it
will not be started. If the service is started before the converge, it will be stopped.
A hash of key value pairs which are set as environment variables to the service process.
The path to the executable to run for the service.
A array of extension configurations.
winsw 'my_winsw_service' do
  executable 'java'
  args %w(-jar C:\\SomeService.jar)
  extensions [{
               :@enabled => 'true',
               :@className => 'winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension',
               :@id => 'killOnStartup',
               :pidfile => '%BASE%\pid.txt',
               :stopTimeout => 5000,
               :stopParentFirst => false,
            }]
endThe above would be rendered as:
<service>
 ...
 <extensions>
  <extension enabled="true" className="winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension" id="killOnStartup">
   <pidfile>%BASE%\pid.txt</pidfile>
   <stopTimeout>5000</stopTimeout>
   <stopParentFirst>false</stopParentFirst>
  </extension>
 </extensions>
</service>Sets the logmode configuration option.
A hash of values to set in the configuration. These may override any of the
properties which are set directly on the resource. The hash is translated into XML.
Regular hash keys are translated directly into  elements and keys prefixed
with @ are treated as attributes.
winsw 'my_winsw_service' do
  executable 'java'
  args %w(-jar C:\\SomeService.jar)
  options :log => {
    :@mode => 'rotate'
  }
end<service>
 <executable>java</executable>
 <arguments>-jar C:\\SomeService.jar</arguments>
 <log mode="rotate"/>
</service>The description used when registering the Windows service. Defaults to windows_serviceName.
The name of the service.
An array of arguments to pass when starting the service.
The Windows service start mode / startup type - e.g. (Automatic, Manual, Disabled)
An array of arguments to pass when stopping the service.
The path to the executable to run for stopping the service (optional).
An array of .NET runtime versions which are set in the WinSW EXE Configuration File.
The name used when registering the Windows service (i.e. the name of the service displayed in services.msc). Defaults to $#{new_resource.name || new_resource.service_name}.
The WinSW exe url.
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request