1. Sebastian Sebastian
  2. scm-manager
  3. Issues

Issues

Issue #349 resolved

Automatic start as service of scm-server on Windows2012Server failing

Juergen Klasen
created an issue

installed scm-manager on a fresh Windows2012Server installation. configured it to run on HTTPS port 8181.

registered it as service (=> scm-server install). service is visible in services manager. clicking on 'start' brings the service up. scm-server is accessible under https://<myhost>:8181/scm. ... good!

configured it for startup typ 'automatic'. rebooted the system. service is not started. event log shows an error that service did not start okay. clicking on 'start' in services manager starts scm-server correctly !?

the log file show the following - for the automatic start attempt:

[2013-03-13 13:53:06] [info] Commons Daemon procrun (1.0.10.0 64-bit) started [2013-03-13 13:53:06] [info] Running 'scm-server' Service... [2013-03-13 13:53:06] [info] Starting service... [2013-03-13 13:53:43] [error] Failed to start Java [2013-03-13 13:53:45] [error] ServiceStart returned 4 [2013-03-13 13:53:47] [info] Run service finished. [2013-03-13 13:53:47] [info] Commons Daemon procrun finished


after (successful) manual start the log file shows (like expected)

[2013-03-13 13:56:03] [info] Commons Daemon procrun (1.0.10.0 64-bit) started [2013-03-13 13:56:03] [info] Running 'scm-server' Service... [2013-03-13 13:56:03] [info] Starting service... [2013-03-13 13:56:05] [info] Service started in 1485 ms.


This phenomenon shows with version 1.22 as well as with the latest version 1.28.

Question: is this a bug in the scm-server code, or more (what I would nearly expect) a - to me - unkonwn "security feature" of Windows2012Server ?

P.S.: Same approach works liek a charm under Windows2008Server, respectively Windows7

Comments (30)

  1. Juergen Klasen reporter

    like written in the report, the scm-manager logs (...\scm-server\var\log\commons-daemon...))show this "[error] Failed to start Java" and "[error] ServiceStart returned 4" for the automatic startup attempt. The corresponding logfile had been attached to the fault report. As the manual start of the service succeeds (same as the start from command shell) I have to assume, that it most probably is no software bug, but more a configuration/setting issue with Windows2012Server.

    I see two potential causes: a) one of the new security features of Windows2012Server doesn't allow the startup to succeed while the system is coming up. or b) there is some kind of dependency introduced with Windows2012Server when it comes to start scm-manager The only other showing of the failed start seems to be in the EventViewer SystemLogs.

  2. Sebastian Sebastian repo owner

    Could you please enable debug logging of procrun. Please uninstall the scm-server service and edit the scm-server.bat, search the line:

    #!bat
    
    "%BASEDIR%\libexec\%PRUNSRV%" //IS//scm-server --Classpath=%CLASSPATH_PREFIX%;%CLASSPATH% --JvmOptions=-Dapp.name="scm-server";-Dapp.repo="%REPO%";-Dbasedir="%BASEDIR%" ++JvmOptions=-Dlogback.configurationFile=logging.xml --DisplayName="scm-server" --Jvm=auto --StartMode=jvm --StartMethod=start --StopMode=jvm --StopMethod=stop --StartClass=sonia.scm.server.ScmServerDaemon --StopClass=sonia.scm.server.ScmServerDaemon --LogPath="%BASEDIR%\var\log" --PidFile="%BASEDIR%\var\scm-server.pid"
    

    and replace the line with:

    #!bat
    "%BASEDIR%\libexec\%PRUNSRV%" //IS//scm-server --LogLevel=Debug --LogJniMessages=1 --Classpath=%CLASSPATH_PREFIX%;%CLASSPATH% --JvmOptions=-Dapp.name="scm-server";-Dapp.repo="%REPO%";-Dbasedir="%BASEDIR%" ++JvmOptions=-Dlogback.configurationFile=logging.xml --DisplayName="scm-server" --Jvm=auto --StartMode=jvm --StartMethod=start --StopMode=jvm --StopMethod=stop --StartClass=sonia.scm.server.ScmServerDaemon --StopClass=sonia.scm.server.ScmServerDaemon --LogPath="%BASEDIR%\var\log" --PidFile="%BASEDIR%\var\scm-server.pid"
    

    After that please enable the automatic startup and reboot the system and post the content of var\log.

  3. Juergen Klasen reporter

    I made sure that I have the latest JRE (JRE7u17 - was u9 before)

    modified the service startup like you said above. Now there are some more lines (surprise :) Essential:


    [...] [2013-03-13 17:20:53] [info] ( prunsrv.c:1089) Starting service... [2013-03-13 17:20:54] [debug] ( javajni.c:195 ) Invalid RuntimeLib 'C:\Program Files\Java\jre7\bin\client\jvm.dll' [...]


    However the start after the system is completely up succeeds without error ...

  4. Juergen Klasen reporter

    before it starts to confuse ... had a look at the scm-server log after a manual (successful) start. it as well shows the message about


    [...] [2013-03-13 17:20:53] [info] ( prunsrv.c:1089) Starting service... [2013-03-13 17:20:54] [debug] ( javajni.c:195 ) Invalid RuntimeLib 'C:\Program Files\Java\jre7\bin\client\jvm.dll' [...]


    So this has nothing to do with the failure of the automatic start !?!

  5. Juergen Klasen reporter

    just redid the same exercise with scm-server 1.22 again. the log contains the information from the failed automatic start, as well as the succeeded manual start.

    to me it seems more and more like an issue between prunsrv and Windows2012Server (?) ...

  6. Juergen Klasen reporter

    I "played around" some more, but couldn't find a reason why the scm-server should not start automatically as service ... For now I gave up, creating a workaround. I left the service as startup type 'manual' and defined in the Group Policy Editor a startup script which automatically executes the manual start of the service ... (> net start scm-server) after the system is up. So now the scm-server is available to all users after system start without manual actions ...

  7. Juergen Klasen reporter

    1st: create a script for starting the service (just a one-liner) : -> "service_start.bat" content: net start scm-server 2nd: place it to your windows folder (e.g.) c:\Windows\System32\GroupPolicy\Machine\Scripts\Startup 3rd: start the management console 'mmc.exe' and open the snapin for 'GroupPolicyObjects' (screenshot screen#1) 4th:Open ComputerConfiguration->WindowsSettings->Scripts. and add a startup script (screenshot screen#2 and screen#3)

    with the next reboot that script shall get executed after system start is complete. this will start the 'scm-server' service then ...

  8. Darkseal

    Hi, I got the same exact problem (with ScmManager 1.32): basically the service doesn't start automatically, but when issued manually it instantly runs without any issues. Any news about that?

  9. Alan Sieving

    I am running scm-server (v1.32 presently) on a Windows Server 2012 Standard installation.

    scm-server starts up automatically just fine for me. Here are two things to check in the registry, to see if something might help:

    In the registry at
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\scm-server

    The key "ImagePath" points to "E:\scm-server\libexec\prunsrv-amd64.exe //RS//scm-server" (E: is where I have my non-microsoft apps)

    The key DependOnService contains "Tcpip Afd"

    Additionally, in the Services window (reachable from the Administrative Tools within the Control Panel) the Properties for scm-server include the following settings on the Recovery tab:

    • First failure: Restart the Service
    • Second failure: Restart the Service
    • Subsequent failures: Take no action
    • Restart service after: 1 minutes

    And of course, the Startup type: on the General tab is set to "Automatic"

    For anyone who is having problems, try some of these settings, and see if that helps. I set it up a year ago, and don't remember what challenges I faced, but I seem to recall that the TCP dependency is crucial to a lot of our installed services.

  10. Sebastian Sebastian repo owner

    Alan Sieving thanks for the tip. I've updated the part of the scm-server.bat script which installs the service. The service is now registered with a dependency to Tcpip and the startup mode is set to automatically. It looks like procrun is not able to change the failure option as you posted above.

    Could somebody test the version below (i have no windows server 2012 at the moment)? It is a 1.34 with a newer version of procrun, commons-daemon and a modified scm-server.bat.

    • uninstall the old service (scm-server.bat uninstall)
    • download the new version (scm-server-app-2013121401.zip)
    • install the new service (scm-server.bat install)
  11. hyltonpeimer

    I tested with 2008 and SCM-Manager does not start with the operating system restarts. Please not however that the server is installed as an AUTOMATIC service. Previously it was installed as MANUAL.

  12. Alan Sieving

    I tried 1.39 on Windows Server 2012, and found the following issues when setting it up as a service to automatically restart with the system.

    1. I get a failure when the scm-server wants to initialize the ADSI connection (Active Directory for authentication) before it is ready. and, only an annoyance:
    2. When I try to stop the service from within the windows service manager, it stops most of the way, but not entirely, so that Windows thinks it is "stopping" even after it reports "Service stop thread completed." This results in the service being unavailable until I reboot the system. Maybe there is a flag or return value that is missing which would tell windows that it has stopped.

    For issue 1, I see the following in the scm-manager.log:

    #!java
    
    "  2014-05-23 18:42:33.238 [Thread-0] ERROR sonia.scm.activedirectory.auth.ActiveDirectoryAuthenticationHandler - Failure initializing ADSI connection
    com4j.ExecutionException: com4j.ComException: 8007054b Failed to MkParseDisplayName : The specified domain either does not exist or could not be contacted. : .\com4j.cpp:217
        at com4j.ComThread.execute(ComThread.java:203) ~[com4j-20120426-2.jar:na]
        at com4j.Task.execute(Task.java:25) ~[com4j-20120426-2.jar:na]
        at com4j.COM4J.getObject(COM4J.java:256) ~[com4j-20120426-2.jar:na]
        at sonia.scm.activedirectory.auth.ActiveDirectoryAuthenticationHandler.init(ActiveDirectoryAuthenticationHandler.java:166) ~[scm-activedirectory-auth-plugin-1.8.jar:na]
        at sonia.scm.ScmInitializerModule$1$1.afterInjection(ScmInitializerModule.java:88) [classes/:na]
    ...
    "
    

    I can resolve this in either of two ways:

    a) by using regedit to add a dependency to the service startup: Adding "DNS" as a dependency to the registry key DependOnService for the scm-server service entry results in the scm-server delaying its startup until the DNS has started, which results in scm-server finding the ActiveDirectory ready for connections.

    b) The other thing that worked was to mark the service as "Automatic (Delayed start)" which delays the start of scm-server until two minutes after everything else has started. This works well except scm isn't available for those two minutes, while (method a) making it delay only until DNS has started gets it going sooner. (The DNS service is dependent upon AFD, TCP, and NTDS, at least in my configuration.)

    Let me know if you need more log files, etc.

    Another thing that would be handy would be either a newer mercurial package with Python 2.7.6. and hg 3.0 or two paragraphs of instructions somewhere in the wiki on how to copy files / set pointers so that the latest hg distribution can be rolled in without waiting for a scm mercurial package. I'm guessing how to do it right now, and I am concerned that I am missing one or two steps. Should I raise this as a separate issue or note it in the google discussion list?

  13. Victor Cheung

    Hi don't want to start a new thread so I just ask it here. I'm using Ubuntu Server and I put the "scm-server/bin/scm-server" in the rc.local "start" section. and if I run /etc/init.d/rc.local start it works and creates the server, but it doesn't load on startup, what did I miss?

    Thanks.

  14. Darkseal

    Victor, no offense but I personally think you should have :D This is a rather complex thread about SCM+Win dependencies and it shouldn't get merged with Ubuntu startup problems and their fixes / workarounds. That's why the "create issue" button exists :)

  15. Log in to comment