Search code examples
tomcatwampwampservertomcat8

Starting/stopping Tomcat using buttons of Wampserver


I installed a server with Wampserver 2.0 which, through the mod_jk connector, I managed to integrate with Tomcat 6 (installed as a windows service). To facilitate, I made some changes to the wampmanager.ini and it was possible to start all services using the WampServer menu. See below:

[Services]
Name: wampapache
Name: wampmysqld
Name: Tomcat6

[StartupAction]
;WAMPSTARTUPACTIONSTART
Action: run; FileName: "D:/wamp/bin/php/php5.3.0/php-win.exe";Parameters: "refresh.php";WorkingDir: "D:/wamp/scripts"; Flags: waituntilterminated
Action: resetservices
Action: readconfig;
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: Tomcat6; ServiceAction: startresume; Flags: ignoreerrors
;WAMPSTARTUPACTIONEND

[StartAll]
;WAMPSTARTALLSTART
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors
Action: service; Service: Tomcat6; ServiceAction: startresume; Flags: ignoreerrors
;WAMPSTARTALLEND

[StopAll]
;WAMPSTOPALLSTART
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: Tomcat6; ServiceAction: stop; Flags: ignoreerrors
;WAMPSTOPALLEND

[RestartAll]
;WAMPRESTARTALLSTART
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: Tomcat6; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampapache; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
Action: service; Service: wampmysqld; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
Action: service; Service: Tomcat6; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
;WAMPRESTARTALLEND

[myexit]
;WAMPMYEXITSTART
Action: service; Service: wampapache; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: wampmysqld; ServiceAction: stop; Flags: ignoreerrors
Action: service; Service: Tomcat6; ServiceAction: stop; Flags: ignoreerrors
Action:  exit
;WAMPMYEXITEND

However, I am upgrading my server, and try to repeat this idea in the Wampserver 3.0.0, it didn't work. Did the changes cited in both the wampmanager.ini and the wampmanager.tpl (which have the same sections to set up), but when using the menu to, for example, start Wampserver, the Tomcat service is not started.

If I start the Tomcat service manually, the integration works, my only problem is to make the start and the termination of all services in a single click, using the WampServer menu.

Can anyone suggest anything?


Solution

  • After exchanging information in Wampserver's forum (read here), managed to solve the problem, I share here the solution of my problem.

    Different from 2.0 version, 3.0.0 version changes are not made in wampmanager.tpl . Changes are described below:

    $WAMP_HOME$\wampmanager.conf

    In [service] tag was created a line for the Tomcat service (in my case, the Tomcat 8.0.30 was installed as a service, called 'tomcat8').

    [service]
    ServiceTomcat = "tomcat8"
    

    $WAMP_HOME$\scripts\config.inc.php

    created variable to Tomcat service

    $c_tomcatService = $wampConf['ServiceTomcat']; 
    

    $WAMP_HOME$\wampmanager.tpl

    changed the tags mentioned in original post above, adding lines with reference to the Tomcat service

    ...
    [Services]
    Name: ${c_tomcatService}
    
    ...
    [StartupAction]
    Action: service; Service: ${c_tomcatService}; ServiceAction: startresume; Flags: ignoreerrors
    
    ...
    [StartAll]
    Action: service; Service: ${c_tomcatService}; ServiceAction: startresume; Flags: ignoreerrors
    
    ...
    [StopAll]
    Action: service; Service: ${c_tomcatService}; ServiceAction: stop; Flags: ignoreerrors
    
    ...
    [RestartAll]
    Action: service; Service: ${c_tomcatService}; ServiceAction: stop; Flags: ignoreerrors waituntilterminated
    Action: service; Service: ${c_tomcatService}; ServiceAction: startresume; Flags: ignoreerrors waituntilterminated
    
    ...
    [myexit]
    Action: service; Service: ${c_tomcatService}; ServiceAction: stop; Flags: ignoreerrors
    

    In first test, didn't work. I discovered that the Tomcat service started by Windows Services Manager, but didn't work when called manually by the prompt or through a batch file (access denied error), even being an administrator on the server.

    The Wampserver's forum suggested me use the SetACL (https://helgeklein.com). With the command below, I was able to change the permissions:

    setacl -on "tomcat8" -ot srv -ace "n:my_login;p:start_stop,read" -actn ace
    

    With this configuration, and using SetACL, I managed to start and stop Tomcat service along with those of Wampserver.