kohsuke/winsw — Issue #6: Service can start first time if eventlog is full.
Author: jbrejner
Created: 2011-11-10 09:45:11+00:00
State: open

A first time installation of Jenkins as windows service, would not start or starts and stops again immediately.

By first time installation I mean, jenkins had never been on the machine before, the operating system was Windows XP.

Attempting to start by hand fails:

C:\>net start jenkins
The jenkins service is starting.
The jenkins service could not be started.

The service did not report an error.

More help is available by typing NET HELPMSG 3534.

but if I do:

java -jar jenkins.war

it jenkins works just as nice as usual

I also found the exact same symptoms if I made the same machine a slave of another jenkins server.

Works if running with java only, but it is not possible to have the service start.

I have checked:
File system rights in jenkins folder (finally set Everyone = Full, recursively)
Added JENKINS_HOME and even JAVA_HOME environment variables
Tried the Windows installer package, to have it install the service. The installation attempts to start the service, which fails, and the installer rolls back.

All to no avail.

Fix that worked for me:

Clear the Windows eventviewer logs for Application and System

Now the service can start.

So I guess this is a problem with the service executable - which is this one: WINSW for both jenkins as service as well as slave as service.

A windows service needs a registry entry under i.e. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\ in order to write to the eventlog for Application(s)

Without investigating the code, I assume that
IF eventlog is full WINSW can not create the new key in registry.
With that missing, it can start logging to the eventvwr - and crashes without any trace.

(from http://howto.praqma.net/hudson/fix-jenkins-service-not-starting)