Bug 48464 - Feature request: startup.bat: -title option needed
Feature request: startup.bat: -title option needed
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Native:Integration
unspecified
PC Windows XP
: P2 enhancement (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2009-12-30 06:08 UTC by LiuYan 刘研
Modified: 2010-01-13 02:43 UTC (History)
0 users



Attachments
Patches for startup.bat(svn#562770), catelina.bat (svn#885002). Usage screenshot (26.66 KB, patch)
2009-12-30 06:08 UTC, LiuYan 刘研
Details | Diff
Patches for startup.bat(svn#562770), catelina.bat(svn#885002) (829 bytes, patch)
2009-12-31 04:04 UTC, LiuYan 刘研
Details | Diff
Patch for catalina.bat#885002 (renew#2), document added (1.29 KB, patch)
2010-01-02 23:27 UTC, LiuYan 刘研
Details | Diff
Patch for catalina.bat#895517 (841 bytes, patch)
2010-01-03 19:00 UTC, LiuYan 刘研
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description LiuYan 刘研 2009-12-30 06:08:15 UTC
Created attachment 24780 [details]
Patches for startup.bat(svn#562770), catelina.bat (svn#885002). Usage screenshot

When running muitiple tomcat instances in same windows OS, the title of all tomcat/DOS window are all "Tomcat", it's a little hard to distinguish which window is which tomcat. 

If a title can be added, for example: 
bin\startup.bat -title "Tomcat Server 1 - XXX" 
bin\startup.bat -title "Tomcat Server 2 - YYY" 
bin\startup.bat -title "Tomcat Server 3 - ZZZ" 
... 

Then I can distinguish these servers from the title of tomcat/DOS window in task bar.
Comment 1 Mark Thomas 2009-12-31 01:21:51 UTC
The preferred format for patches is diff -u

The screen shot is unnecessary and makes the attachment 50 [details] times bigger than it needs to be.

I am -1 for the patch as is since it makes Title a mandatory parameter for catalina.bat. This would be an added nuisance for far more users that it would benefit.

I'd suggest using an environment variable for the title that defaults to Tomcat
Comment 2 LiuYan 刘研 2009-12-31 04:04:48 UTC
Created attachment 24784 [details]
Patches for startup.bat(svn#562770), catelina.bat(svn#885002)

-t, -title: specify a title
-tt, -timetitle: specify a title, and append current time to title
Comment 3 Mark Thomas 2009-12-31 04:17:25 UTC
Thanks for the updated patch. It is heading in the right direction but maybe I wasn't clean enough in my previous comments.

I do not believe this should be configurable via a command line parameter for startup.bat nor catalina.bat. This should simply be a system property that can be set in setenv.bat if required.

Take a look at catalina.bat and how, for example, how LOGGING_MANAGER is used.
Comment 4 LiuYan 刘研 2009-12-31 05:23:57 UTC
(In reply to comment #3)
> Thanks for the updated patch. It is heading in the right direction but maybe I
> wasn't clean enough in my previous comments.
> I do not believe this should be configurable via a command line parameter for
> startup.bat nor catalina.bat. This should simply be a system property that can
> be set in setenv.bat if required.
> Take a look at catalina.bat and how, for example, how LOGGING_MANAGER is used.

Hi Mark:

Pass title via command line parameter is just a convenient usage.

If it's not prefered, then only apply the lastest patch for catalina.bat (if it's acceptable) can works as what you mean in comment #1. In the latest patch for catalina.bat, TITLE and STARTUP_TIME environment varaibles are readed and passed to _EXECJAVA.



By the way:
If %CD% contains "&" character, the startup.bat will failed at
cd %CURRENT_DIR%

%CURRENT_DIR% need to be quoted to avoid this error. "cd %CURRENT_DIR%" exists in startup.bat, shutdown.bat, catalina.bat, service.bat, version.bat, should I post a new bug?
Comment 5 Mark Thomas 2009-12-31 05:27:50 UTC
(In reply to comment #4)
> If it's not prefered, then only apply the lastest patch for catalina.bat (if
> it's acceptable) can works as what you mean in comment #1. In the latest patch
> for catalina.bat, TITLE and STARTUP_TIME environment varaibles are readed and
> passed to _EXECJAVA.

The new environment variables still need to be documented in the same way as the other environment variables.

> By the way:
> If %CD% contains "&" character, the startup.bat will failed at
> cd %CURRENT_DIR%
> 
> %CURRENT_DIR% need to be quoted to avoid this error. "cd %CURRENT_DIR%" exists
> in startup.bat, shutdown.bat, catalina.bat, service.bat, version.bat, should I
> post a new bug?

Yes please.
Comment 6 LiuYan 刘研 2010-01-02 23:27:06 UTC
Created attachment 24788 [details]
Patch for catalina.bat#885002 (renew#2), document added

Patch updated.
I documented these environment variables in this patch, hope there's no chinglish in it:

TITLE           (Optional) Specify the title of Tomcat window. The default
                TITLE is Tomcat if it's not specified.
                Example (all one line)
                set TITLE=Tomcat Server 1

TITLE_WITH_TIME (Optional) If set, regardless the value of it, current
                datetime will be appended to title, so that you can know
                the startup time of Tomcat from title.
                Example (all one line)
                set TITLE_WITH_TIME=whatever non empty value
Comment 7 Konstantin Kolinko 2010-01-03 05:03:25 UTC
Re startup.bat:

Please note, that since TC 6.0.16/5.5.26 you can create %CATALINA_BASE%/bin/setenv.bat, and place your instance-specific variable assignments there.

Also you can write your own simple script to process -t and -tt arguments, set the varables, and call startup.bat (or directly "catalina.bat start").

Because the title can be set programmatically in those scripts, I see no point in providing the 'TITLE_WITH_TIME' variable.


Re Comment 4:
> If %CD% contains "&" character, the startup.bat will failed at
> cd %CURRENT_DIR%
> %CURRENT_DIR% need to be quoted to avoid this error.

For me it fails a few lines earlier, when executing
set CURRENT_DIR=%cd%

The solution is to add quotes to the set command as well:
set "CURRENT_DIR=%cd%"

The above is on Windows XP.
I will work on a patch, though will need to wait till the end of the holidays to test on the other Windows versions as well.
Comment 8 Konstantin Kolinko 2010-01-03 06:57:53 UTC
Re Comment 4:
> If %CD% contains "&" character, the startup.bat will failed at
Fixed in trunk (r895191, r895392), proposed for TC 6.0
Comment 9 LiuYan 刘研 2010-01-03 19:00:10 UTC
Created attachment 24790 [details]
Patch for catalina.bat#895517

(In reply to comment #7)
> Re startup.bat:
> Please note, that since TC 6.0.16/5.5.26 you can create
> %CATALINA_BASE%/bin/setenv.bat, and place your instance-specific variable
> assignments there.
> Also you can write your own simple script to process -t and -tt arguments, set
> the varables, and call startup.bat (or directly "catalina.bat start").
> Because the title can be set programmatically in those scripts, I see no point
> in providing the 'TITLE_WITH_TIME' variable.

Ok, I'll write my own batch script to process command line arguments.
And 'TITLE_WITH_TIME' is removed. This patch seems tidy now. :)

For one installation one instance situation, tomcat users can specify TITLE in %CATALINA_BASE%/bin/setenv.bat.

For running multiple instances from one tomcat installation situation, tomcat users need to write their own script to have different TITLEs. for example:

start_clustered_servers.cmd
-----------------
@echo off
set CATALINA_HOME=apache-tomcat-6.0.22

set CATALINA_BASE=server1_1
set TITLE=Tomcat.Cluster#1.Server#1 [%DATE% %TIME%]
call "%CATALINA_HOME%\bin\startup.bat"

set CATALINA_BASE=server1_2
set TITLE=Tomcat.Cluster#1.Server#2 [%DATE% %TIME%]
call "%CATALINA_HOME%\bin\startup.bat"

set CATALINA_BASE=server2_1
set TITLE=Tomcat.Cluster#2.Server#1 [%DATE% %TIME%]
call "%CATALINA_HOME%\bin\startup.bat"

REM ...
-----------------

> Re Comment 4:
> > If %CD% contains "&" character, the startup.bat will failed at
> > cd %CURRENT_DIR%
> > %CURRENT_DIR% need to be quoted to avoid this error.
> For me it fails a few lines earlier, when executing
> set CURRENT_DIR=%cd%

My mistake, The failed line is "set CURRENT_DIR=%cd%".

> The solution is to add quotes to the set command as well:
> set "CURRENT_DIR=%cd%"
> The above is on Windows XP.
> I will work on a patch, though will need to wait till the end of the holidays
> to test on the other Windows versions as well.

That's GREAT !!!
When I try to resolve this problem, I only know the usage of place double quote around %CD% --> "%CD", I do not know the quote can include the variable name ⊙_⊙, so I encounted another problem when referencing CURRENT_DIR/CATALINA_HOME/... with another double quotes around ("%CURRENT_DIR%" --> ""C:\Tomcat Cluster & LoadBalance Test"").
Comment 10 Mark Thomas 2010-01-04 03:33:43 UTC
Patch looks good to me. I have applied it to trunk and proposed it for 6.0.x.

I have credited the patch to "LiuYan". If this is wrong, let me know the correct name to use and I'll make the necessary changes.
Comment 11 Mark Thomas 2010-01-13 02:43:42 UTC
The patch has been applied to 6.0.x and will be included in 6.0.23 onwards.