jenkins service fail to start on windows 2008

2020-07-17 16:35发布

I'm trying to get Jenkins installed as a service on a Windows Server 2008 Datacenter (SP2). I can't seem to get it to run as a service and am looking for any ideas to help get it going.

When I try install Jenkins with native Windows package I get "Error 1920. Service Jenkins failed to start." in msiexec logs.

I've performed the following steps for manual installation:

  • Installed java 32 bit
  • Started Jenkins with java -jar jenkins.war
  • Gone to Manage Jenkins and set it to run as a Windows Service.
  • Told Jenkins to restart itself as a service.

At this point, Jenkins dies and doesn't come back up.

When I try and manually start Jenkins I get error 1053 (service did not respond). I can't spot any log files or other information.

Any ideas or suggestions welcome, I'd also be curious to hear from anyone who has got it working on this O/S (or a windows 2003 server).

Many Thanks

7条回答
男人必须洒脱
2楼-- · 2020-07-17 16:41

I got same issue & resolved by setting up Java dir path.

查看更多
不美不萌又怎样
3楼-- · 2020-07-17 16:45

I had similar problems on windows 2003 server. I had already installed .net framwork 4.0 but jenkins (v1.4.60) does not work with this framework. After installing .net framework 2.0 (v2.0.50727) the problem was resolved.

查看更多
神经病院院长
4楼-- · 2020-07-17 16:52

I had the same problem but for me it was a problem with the jenkins.xml configuration file. It was not proper XML and thus Jenkins could not load it properly. I found out that it was a configuration error by executing jenkins.exe in a command prompt as administrator, it gave me a proper error output.

查看更多
放荡不羁爱自由
5楼-- · 2020-07-17 16:54

I found the default setting of the Jenkins service to allow only 256m of HEAP. I guess they expected us to code only "Hello World". I found this after occasional PermGen errors. But I found that I could not correct jenkins.xml with all of,

-Xrs -Xms<value> -Xmx<value> --XX:PermSize=<value> --XX:MaxPermSize=<value>

I could only start Jenkins while setting,

-Xrs -Xms<value> -XX:MaxPermSize=<value>
查看更多
我命由我不由天
6楼-- · 2020-07-17 16:58

Suggestion: if you can at all avoid it, do not run Jenkins as a service on Windows - you may get into all kinds of problems connected to permissions and running in the background. The downside is that it won't start automatically when the machine restarts, but more often than not one can live with that. In my experience Jenkins is very robust as far as crashing is concerned. If you want to be extra careful - write a wrapper that checks every so often that Jenkins is alive (say, via trying to connect to it via HTTP) and restarts it if it has died.

Attached is a Python script that does that (no warranties, liabilities, etc.):

'''Usage:
hudson.py [<http-port>]'''

# Script to start/revive Hudson/Jenkins
# The script checks if Hudson is alive by trying to connect to its HTTP port
# if connection fails - it tries to restart Hudson 

import sys
import time
import httplib
import os

HTTPTimeout = 10
CheckInterval = 300
DefaultHudsonPort = 8081

if (__name__ == '__main__'):
    if len(sys.argv) > 2:
        print __doc__
        sys.exit(1)
    elif len(sys.argv) == 2:
        portNum = int(sys.argv[1])
    else:
        portNum = DefaultHudsonPort

    httpConnection = None
    while True:
        if not httpConnection:
            httpConnection = httplib.HTTPConnection("127.0.0.1", portNum, timeout = HTTPTimeout)
        try:
            httpConnection.connect()
            httpConnection.close()
        except:
            print "(Re)Starting Hudson/Jenkins on port %d" % portNum
            os.system("java -jar hudson.war --httpPort=%d" % portNum)
        time.sleep(CheckInterval)
查看更多
霸刀☆藐视天下
7楼-- · 2020-07-17 17:07

Version 1.498 has stronger security which can break Jenkins Slave as a service.

https://issues.jenkins-ci.org/browse/JENKINS-16273

Recommendations include:

  1. Stop service
  2. Uninstall the service if it exists dos (sc delete jenkinsslave-C__Jenkins)
  3. Delete the old jenkins-slave.exe, slave.jar and jenkins-slave.xml
  4. Start the web client and let it install the service
  5. Edit the jenkins-slave.xml so the it looks like this the important part is the jnlpCredentials <arguments>-Xrs -jar "%BASE%\slave.jar" -jnlpCredentials <user>:<password> -jnlpUrl http://<your server>/computer/<slave name>/slave-agent.jnlp</arguments>

I found deleting slave.jar and starting the web client as a logged in user worked best, you get a secret and don't need to edit the XML.

If I don't delete slave.jar that I found editing jenkins-slave.xml and removing the secret in arguments works without any credentials at all (a security hole?). See jenkins-slave.err

"-secret" is not a valid option

jenkins-slave.xml

...
<service>
  <id>jenkinsslave-D__Jenkins</id>
  <name>Jenkins Slave</name>
...
  <executable>C:\Program Files\Java\jre7\bin\java.exe</executable>
  <arguments>-Xrs  -jar "%BASE%\slave.jar" -jnlpUrl http://jenkins.domain/jenkins/computer/mycomputername/slave-agent.jnlp </arguments> <!-- -secret fafd7bf18fdcc48ffb17fe1ff0a072ce5d33b004769b351e9d633f875b63fb59 -->
...
查看更多
登录 后发表回答