Bug 900708 (JBPAPP6-1436) - Starting EAP as a service on Windows does not work with the startup scripts (standalone.bat/domain.bat)
Summary: Starting EAP as a service on Windows does not work with the startup scripts (...
Keywords:
Status: CLOSED NEXTRELEASE
Alias: JBPAPP6-1436
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Scripts and Commands
Version: unspecified
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: EAP 6.2.0
Assignee: Tom Fonteyne
QA Contact:
URL: http://jira.jboss.org/jira/browse/JBP...
Whiteboard:
Depends On:
Blocks: 1006345 1006346
TreeView+ depends on / blocked
 
Reported: 2012-07-13 08:17 UTC by Madhumita Sadhukhan
Modified: 2014-01-13 23:56 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-09-17 16:18:00 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
service_v1.bat (2.57 KB, application/octet-stream)
2012-08-20 12:59 UTC, Tom Fonteyne
no flags Details
service_v2.bat (3.18 KB, application/octet-stream)
2012-09-06 14:02 UTC, Tom Fonteyne
no flags Details
service_v3.bat (6.17 KB, application/octet-stream)
2012-09-14 12:48 UTC, Tom Fonteyne
no flags Details
service_v4.bat (6.18 KB, application/octet-stream)
2012-10-03 05:20 UTC, George Rypysc
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 732889 0 medium CLOSED Instructions for installing JBoss as Windows service do not work 2021-02-22 00:41:40 UTC
Red Hat Issue Tracker JBPAPP6-1436 0 Major Closed Starting EAP as a service on Windows does not work with the startup scripts (standalone.bat/domain.bat) 2017-01-11 07:40:19 UTC

Internal Links: 732889

Description Madhumita Sadhukhan 2012-07-13 08:17:23 UTC
project_key: JBPAPP6

Please refer bugzilla issue below for details:

https://bugzilla.redhat.com/show_bug.cgi?id=834255

Executing command

"prunsrv.exe install path_to_startup_script"

yields following results
The service is installed. JBoss Enterprise Application Platform 6 is listed in the Services applet services.msc."

However, I could not find any such service in Services applet.Only prunsrv service was added.

Are the startup scripts not equipped for this feature?

Comment 1 Madhumita Sadhukhan 2012-07-13 08:19:47 UTC
With reference to Bugzilla issue I created earlier twells is asking for information.However I think this does not work and needs to be fixed.
@Rajesh
When I selected Scripts component this remained unassigned.Please reassign to concerned person who could look into this.

Comment 2 James Livingston 2012-07-26 06:28:23 UTC
This is being worked on at https://bugzilla.redhat.com/show_bug.cgi?id=834255

Comment 3 RH Bugzilla Integration 2012-07-26 06:28:42 UTC
Bugzilla Update: Added: Perform


Comment 4 RH Bugzilla Integration 2012-07-26 06:28:43 UTC
Bugzilla References: Added: https://bugzilla.redhat.com/show_bug.cgi?id=732889


Comment 5 Madhumita Sadhukhan 2012-07-30 12:56:38 UTC
Hi James,

          So should I assign this to you?I believe the scripts need to be fixed.

Comment 6 RH Bugzilla Integration 2012-07-30 13:14:19 UTC
Tom Fonteyne <tfonteyn> made a comment on [bug 732889|https://bugzilla.redhat.com/show_bug.cgi?id=732889]

I think I have the full solution:

1. Make sure to set JBOSS_HOME as a system environment variable pointing to the JBoss installation directory

2. Add a system environment variable NOPAUSE=1
   Alternatively edit the last line of both   standalone.bat (domain.bat) / jboss-cli.bat
   and remove this line:
       if "x%NOPAUSE%" == "x" pause

3.Open a cmd.exe window

4. execute a  "set JBOSS_HOME=..."
  (not needed if you open the cmd.exe *after* you have added the system env. var)

5. Installing the service, enter the below on one line:

prunsrv //IS//JBossEAP6 --DisplayName="JBoss Enterprise Application Platform 6" --LogLevel=DEBUG --LogPath=%JBOSS_HOME%\standalone\log\ --LogPrefix=service --StdOutput=auto --StdError=auto --StartMode=exe --StartImage=cmd.exe --StartPath=%JBOSS_HOME%/bin ++StartParams="/c standalone.bat" --StopMode=exe --StopImage=cmd.exe --StopPath=%JBOSS_HOME%/bin  ++StopParams="/c jboss-cli.bat --connect command=:shutdown"

Adjust loglevel as required of course (f.e. just INFO) or use "domain" instead of "standalone" for executable and path as needed.

6. You should now have a service installed that you can manually start/stop from the Services window.
   Set to automatic is so required.

Should you need to remove the service, use this:

prunsrv //DS//JBossEAP6

Comment 7 RH Bugzilla Integration 2012-07-30 13:20:30 UTC
Tom Fonteyne <tfonteyn> made a comment on [bug 732889|https://bugzilla.redhat.com/show_bug.cgi?id=732889]

it is probably the cleanest if the above gets combined in a "service.bat" that takes commands line "install,start,stop,restart" just like JBoss 5 provided.

Let me know, and I can knock on up.

Comment 8 RH Bugzilla Integration 2012-07-31 03:26:44 UTC
James Livingston <jlivings> made a comment on [bug 732889|https://bugzilla.redhat.com/show_bug.cgi?id=732889]

Yeah, that would work. I probably avoided that because you couldn't do it in EAP 4/5 without including the credential details - EAP 6 you can because of local authentication.

Comment 9 RH Bugzilla Integration 2012-08-17 02:01:59 UTC
Jason Shepherd <jshepherd> made a private comment on [bug 732889|https://bugzilla.redhat.com/show_bug.cgi?id=732889]

Comment 10 RH Bugzilla Integration 2012-08-17 07:58:30 UTC
Tom Fonteyne <tfonteyn> made a private comment on [bug 732889|https://bugzilla.redhat.com/show_bug.cgi?id=732889]

Comment 11 RH Bugzilla Integration 2012-08-19 22:40:34 UTC
Jason Shepherd <jshepherd> made a private comment on [bug 732889|https://bugzilla.redhat.com/show_bug.cgi?id=732889]

Comment 12 RH Bugzilla Integration 2012-08-20 06:43:56 UTC
Jason Shepherd <jshepherd> made a private comment on [bug 732889|https://bugzilla.redhat.com/show_bug.cgi?id=732889]

Comment 13 RH Bugzilla Integration 2012-08-20 10:53:48 UTC
Tom Fonteyne <tfonteyn> made a comment on [bug 732889|https://bugzilla.redhat.com/show_bug.cgi?id=732889]

In replacement of my comment #15, covering domain mode + a little cleanup, the following can be added the documentation:

=====================================================================
1. Add a system environment variable NOPAUSE=1
   Alternatively edit the last line of both
       standalone.bat (domain.bat) / jboss-cli.bat
   and remove this line:
       if "x%NOPAUSE%" == "x" pause

2. Open a cmd.exe window

3. execute a  "set JBOSS_HOME=..." or use the full path in the below statement

4. Installing the service, enter one of the below on one line:

For standalone:

prunsrv //IS//JBossEAP6 --DisplayName="JBoss Enterprise Application Platform 6" --LogLevel=INFO --LogPath=%JBOSS_HOME%\standalone\log\ --LogPrefix=service --StdOutput=auto --StdError=auto --StartMode=exe --StartImage=cmd.exe --StartPath=%JBOSS_HOME%/bin ++StartParams="/c standalone.bat" --StopMode=exe --StopImage=cmd.exe --StopPath=%JBOSS_HOME%/bin  ++StopParams="/c jboss-cli.bat --connect command=:shutdown"

For domain mode:

prunsrv //IS//JBossEAP6 --DisplayName="JBoss Enterprise Application Platform 6" --LogLevel=INFO --LogPath=%JBOSS_HOME%\domain\log\ --LogPrefix=service --StdOutput=auto --StdError=auto --StartMode=exe --StartImage=cmd.exe --StartPath=%JBOSS_HOME%/bin ++StartParams="/c domain.bat" --StopMode=exe --StopImage=cmd.exe --StopPath=%JBOSS_HOME%/bin  ++StopParams="/c jboss-cli.bat --connect command=/host=master:shutdown"

Note the difference in shutdown command. If not using the default "master", make sure to add the right host name or alias you used for the domain controller

Adjust loglevel as required of course.

5. You should now have a service installed that you can manually start/stop
   from the Services window. Set to automatic if so required.

Should you need to remove the service, use this:

prunsrv //DS//JBossEAP6
=====================================================================

Comment 14 Tom Fonteyne 2012-08-20 12:54:56 UTC
Bugzilla References: Removed: https://bugzilla.redhat.com/show_bug.cgi?id=732889 Added: https://bugzilla.redhat.com/show_bug.cgi?id=732889


Comment 15 Tom Fonteyne 2012-08-20 12:59:21 UTC
I created the attached service.bat for EAP 6.0 usage.

Copy it to the modules\native\sbin directory

It's a first attempt but does the job

Usage:

service.bat install
   => installs standalone.sh

service.bat install domain
   => installs domain.sh

Other options:

service.bat uninstall
service.bat start
service.bat stop
service.bat restart

You can edit the section at the top to change log level or service name.
For domain mode, it uses "master" for the domain controller. Change when needed

todo:
- nicer user messages like for example change the printing of the errorlevel
- have options for DC and loglevel

Comment 16 Tom Fonteyne 2012-08-20 12:59:21 UTC
Attachment: Added: service_v1.bat


Comment 17 Tom Fonteyne 2012-08-20 13:05:07 UTC
Link: Added: This issue is related to PRODMGT-219


Comment 18 Nuno Ferreira 2012-08-27 15:27:14 UTC
Hi, 

Using Tom´s script and the problem is that the domain controller don´t stop, or better, it stops, but the windows service remains in stopping state forever until the machine restarts.

anyone have this behavior? 

Using windows 2008 r2 server.

cheers

Comment 19 Jacek Palka 2012-08-28 09:11:11 UTC
Hi,

I've tried to use the suggested work around, but the service has not been possible to stop - the Java processes went down, but the prunsrv.exe process was still running making the service to be marked as "Stopping" in the Server Manager. First after I've killed the process in the Task Manager the service has been stopped. I was testing on Windows 2008 R2.

Comment 20 Nuno Ferreira 2012-08-28 09:20:30 UTC
I´ve come up with the solution.

I´ve to remove all the section of the domain.bat (i believe its the same as standalone.bat):
":END
if "x%NOPAUSE%" == "x" pause

:END_NO_PAUSE"

After doing this the windows service works well.

cheers.

Comment 21 RH Bugzilla Integration 2012-09-03 10:55:12 UTC
Tom Fonteyne <tfonteyn> made a comment on [bug 732889|https://bugzilla.redhat.com/show_bug.cgi?id=732889]

yes, that bit is missing from the service script which is not finalized yet.
I'll work that in later

Comment 22 Tom Fonteyne 2012-09-06 14:02:34 UTC
Attachment: Added: service_v2.bat


Comment 23 Tom Fonteyne 2012-09-06 14:05:50 UTC
I added the NOPAUSE support into the script. There is now no need any more to set environment variables or modify the standalone/domain.bat files.

service_v2.bat 06/Sep/12

Rename it to "service.bat" and copy it to the modules\native\sbin directory

Usage:

service.bat install
=> installs standalone.sh

service.bat install domain
=> installs domain.sh

Other options:

service.bat uninstall
service.bat start
service.bat stop
service.bat restart

You can edit the section at the top to change log level or service name.
For domain mode, it uses "master" for the domain controller. Change when needed.

todo:

 - nicer user messages like for example change the printing of the errorlevel
 - have options for DC and loglevel


Comment 24 Tom Fonteyne 2012-09-14 12:48:47 UTC
Attachment: Added: service_v3.bat


Comment 25 Tom Fonteyne 2012-09-14 12:53:54 UTC
service_v3.bat 14/Sep/12

- fixed the location for the service logfile
- added command line options for all settings, no need to edit the script any longer
  => this means a change in the syntax for installing in domain mode !
- better help

Install: Download service_v3.bat, rename it to "service.bat" and copy it to the modules\native\sbin directory

Run the batch file without arguments to get usage information.

still todo:

    nicer user messages like for example change the printing of the errorlevel

Comment 26 George Rypysc 2012-10-03 05:20:09 UTC
service_v4.bat - Small changes to properly handles spaces in LogPath, StartPath, and StopPath and fix "Succes" typo.

Comment 27 George Rypysc 2012-10-03 05:20:09 UTC
Attachment: Added: service_v4.bat


Comment 28 Anne-Louise Tangring 2012-11-13 20:57:59 UTC
Docs QE Status: Removed: NEW 


Comment 29 JBoss JIRA Server 2013-01-25 07:58:00 UTC
RH Bugzilla Integration <no-reply> updated the status of jira JBPAPP6-1436 to Closed

Comment 30 Vaclav Tunka 2013-09-17 16:18:00 UTC
This will be delivered in EAP 6.2.0 ER2. See BZ1006346 which tracks all the relevant info. Closing.


Note You need to log in before you can comment on or make changes to this bug.