ports/75143: There is no way to specify jvm parameters when starting jakarta-tomcat.

Anton Yudin toha at toha.org.ua
Thu Dec 16 10:10:19 UTC 2004


>Number:         75143
>Category:       ports
>Synopsis:       There is no way to specify jvm parameters when starting jakarta-tomcat.
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 16 10:10:18 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Anton Yudin
>Release:        FreeBSD 4.10-STABLE i386
>Organization:
>Environment:
System: FreeBSD .ua 4.10-STABLE FreeBSD 4.10-STABLE #0: Fri Oct 15 17:10:27 EEST 2004 root at .ua:/obj/usr/src/sys/ i386


	
>Description:
	There is no way to specify jvm parameters when starting jakarta-tomcat.
	
>How-To-Repeat:
	
>Fix:
	Patch www/jakarta-tomcat5/Makefile and www/jakarta-tomcat4/files/daemonctl.c

	Now it is possible to specify parameters for jvm in such way:
	tomcat50ctl start [jvm-arguments]
	for example:
	tomcat50ctl start -server -Xmx128m

*** www/jakarta-tomcat5/Makefile.original	Tue Dec 14 16:38:37 2004
--- www/jakarta-tomcat5/Makefile	Tue Dec 14 16:18:02 2004
***************
*** 124,131 ****
  
  	@${ECHO_CMD} -n ">> Compiling and installing control program..."
  	@${SED} \
! 	-e "/%%JAVA_ARGS%%/s//\"-Dcatalina.home=${APP_HOME:S/\//\\\//g}\",/g" \
! 	-e "/%%JAR_ARGS%%/s//\"start\",/g" \
  	${WRKDIR}/daemonctl.c > ${WRKDIR}/daemonctl_.c
  	@cd ${WRKDIR} && ${CC} -ansi -o ${CONTROL_SCRIPT_NAME} daemonctl_.c
  	@${CP} ${WRKDIR}/${CONTROL_SCRIPT_NAME} ${CONTROL_SCRIPT}
--- 124,131 ----
  
  	@${ECHO_CMD} -n ">> Compiling and installing control program..."
  	@${SED} \
! 	-e "/%%JAVA_ARGS%%/s//-Dcatalina.home=${APP_HOME:S/\//\\\//g}/g" \
! 	-e "/%%JAR_ARGS%%/s//start/g" \
  	${WRKDIR}/daemonctl.c > ${WRKDIR}/daemonctl_.c
  	@cd ${WRKDIR} && ${CC} -ansi -o ${CONTROL_SCRIPT_NAME} daemonctl_.c
  	@${CP} ${WRKDIR}/${CONTROL_SCRIPT_NAME} ${CONTROL_SCRIPT}

*** www/jakarta-tomcat4/files/daemonctl.c.original	Thu Oct 10 02:10:32 2002
--- www/jakarta-tomcat4/files/daemonctl.c	Thu Dec 16 11:48:24 2004
***************
*** 57,62 ****
--- 57,64 ----
  private void restart(void);
  
  
+ char** applicationArguments = NULL;
+ 
  /**
   * Main function. This function is called when this program is executed.
   *
***************
*** 84,93 ****
--- 86,97 ----
  
  	argument = argv[1];
  	if (strcmp("start", argument) == 0) {
+ 		applicationArguments = argv + 2;
  		start();
  	} else if (strcmp("stop", argument) == 0) {
  		stop();
  	} else if (strcmp("restart", argument) == 0) {
+ 		applicationArguments = argv + 2;
  		restart();
  	} else {
  		fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Illegal argument \"%s\".\n", argument);
***************
*** 313,318 ****
--- 317,325 ----
  	int stdoutLogFile;
  	int stderrLogFile;
  	struct stat sb;
+ 	char** arguments = NULL;
+ 	int ac = 0;
+ 	int i = 0;
  
  	/* Open and read the PID file */
  	printf(">> Reading PID file (%%PID_FILE%%)...");
***************
*** 415,420 ****
--- 422,449 ----
  
  	if (pid == 0) {
  
+ 		if (applicationArguments != NULL)
+ 			for (;applicationArguments[ac] != NULL;ac++)
+ 
+ 		fprintf(stderr, "ac = %i\n", ac);
+ 
+ 		arguments = malloc(sizeof(char*) * 6 + ac);
+ 
+ 		arguments[0] = "%%JAVA_HOME%%/%%JAVA_CMD%%";
+ 		for (i = 0; i < ac; i++)
+ 			arguments[1 + i] = applicationArguments[i];
+ 		arguments[1 + i] = "-jar";
+ 		arguments[2 + i] = "%%JAVA_ARGS%%";
+ 		arguments[3 + i] = "%%JAR_FILE%%";
+ 		arguments[4 + i] = "%%JAR_ARGS%%";
+ 		arguments[5 + i] = NULL;
+ 
+ #ifdef DEBUG
+ 		for (ac = 0; ac < i + 5; ac++) {
+ 			fprintf(stderr, "arg[%i] = (%s)\n", ac, arguments[ac]);
+ 		}
+ #endif
+ 
  		/* Redirect stdout to log file */
  		dup2(stdoutLogFile, STDOUT_FILENO);
  
***************
*** 425,431 ****
  		         file using pipe(2) */
  
  		/* Execute the command */
! 		execl("%%JAVA_HOME%%/%%JAVA_CMD%%", "%%JAVA_HOME%%/%%JAVA_CMD%%", "-jar", %%JAVA_ARGS%% "%%JAR_FILE%%", %%JAR_ARGS%% NULL);
  
  		fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to start %%APP_TITLE%% %%PORTVERSION%% since '%%JAVA_HOME%%/%%JAVA_CMD%% -jar %%JAR_FILE%%' in %%APP_HOME%%: ");
  		perror(NULL);
--- 454,460 ----
  		         file using pipe(2) */
  
  		/* Execute the command */
! 		execv("%%JAVA_HOME%%/%%JAVA_CMD%%", arguments);
  
  		fprintf(stderr, "%%CONTROL_SCRIPT_NAME%%: Unable to start %%APP_TITLE%% %%PORTVERSION%% since '%%JAVA_HOME%%/%%JAVA_CMD%% -jar %%JAR_FILE%%' in %%APP_HOME%%: ");
  		perror(NULL);
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list