java setenv.sh 在单独的 tomcat catalina 基础中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4133302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 04:55:28  来源:igfitidea点击:

setenv.sh in an individual tomcat catalina base

javatomcatservletssetenvcatalina

提问by ziggy

At the moment i have several catalina bases configured with the following directories,

目前我有几个配置了以下目录的 catalina 库,

conf logs server webapps work

conf 日志服务器 webapps 工作

The bin, lib and common directories are all still in $CATALINA_HOME.

bin、lib 和 common 目录仍然在 $CATALINA_HOME 中。

I now need to add a setenv.sh file in the bin directory but i dont want it to be used by all the catalina bases. To do this i am thinking of adding a bin diretory on the catalina_base that i want to pick up the setenv.sh file. The bin directory will only contain the setenv.sh file and nothing else. Everything else will still be in $CATALINA_HOME/bin/ (ie. startup.sh catalina.sh shutdown.sh etc)

我现在需要在 bin 目录中添加一个 setenv.sh 文件,但我不希望所有 catalina 库都使用它。为此,我正在考虑在 catalina_base 上添加一个 bin 目录,我想获取 setenv.sh 文件。bin 目录将只包含 setenv.sh 文件,不包含其他任何内容。其他所有内容仍将在 $CATALINA_HOME/bin/ 中(即 startup.sh catalina.sh shutdown.sh 等)

Are there any side effects to doing this? Can tomcat use both $CATALINA_BASE/bin/ and $CATALINA_HOME/bin during startup?

这样做有什么副作用吗?tomcat 可以在启动时同时使用 $CATALINA_BASE/bin/ 和 $CATALINA_HOME/bin 吗?

回答by bartosz.r

I have not tested how it behaves if you provide a bin with setenv.sh. But this is my way of configuring many tomcat applications running different instances from one CATALINA_HOME.

如果你提供一个带有 setenv.sh 的 bin,我还没有测试它的行为。但这是我从一个 CATALINA_HOME 配置许多运行不同实例的 tomcat 应用程序的方式。

If you have that configuration, then you probably have your own startup script that does run catalina.sh. with options JAVA_HOME, CATALINA_HOME, CATALINA_BASE, and probably CATALINA_PID.

如果您有该配置,那么您可能有自己的启动脚本,可以运行 catalina.sh。带有选项 JAVA_HOME、CATALINA_HOME、CATALINA_BASE,可能还有 CATALINA_PID。

So whatever you need to change or to add in setenv.sh, just change in your own startup script. Or create your setenv.sh that will be called at the beggining of your start script. And put this in your own bin directory.

因此,无论您需要更改或添加 setenv.sh,只需更改您自己的启动脚本即可。或者创建将在启动脚本开始时调用的 setenv.sh。并将其放在您自己的 bin 目录中。

I assume it is linux (in windows it will be similar). So you can have a few applicaitons, lets call them APP1, APP2. Both have: bin conf logs server webapps work. the directory structure can be:

我假设它是 linux(在 Windows 中它会类似)。所以你可以有几个应用程序,让我们称它们为APP1、APP2。两者都有:bin conf logs server webapps work。目录结构可以是:

/apps/APP1
   bin
      start.sh
      stop.sh
   conf
   logs
   server
   webapps
   work
/apps/APP2
   bin
      start.sh
      stop.sh
   conf
   logs
   server
   webapps
   work
/opt/apache-tomcat-xxx
   all the standard tomcat files...
/opt/java-1.6
   all the standard java files...

And in start.sh for APP1 you can set: JAVA_HOME, CATALINA_HOME, CATALINA_BASE, and probably CATALINA_PID, CATALINA_OPTS.

在 APP1 的 start.sh 中,您可以设置:JAVA_HOME、CATALINA_HOME、CATALINA_BASE,可能还有 CATALINA_PID、CATALINA_OPTS。

export JAVA_HOME=/opt/java-1.6
export CATALINA_HOME=/opt/apache-tomcat-xxx
export CATALINA_BASE=/apps/APP1
export CATALINA_PID=${CATALINA_BASE}/temp/app1.pid.file
export CATALINA_OPTS=-Dmy.fancy.variable=hello

${CATALINA_HOME}/bin/catalina.sh start

Stop will be almost the same. You only need to change start to stop. next step will be to move variable definitions to some file, let's say config.ini and then you have to source this file in start.sh and also in stop.sh. In windows, you need to change export to set. In different shells (if not bash) you need to follow the instructions.

停止将几乎相同。您只需将开始更改为停止。下一步是将变量定义移动到某个文件中,比如说 config.ini,然后你必须在 start.sh 和 stop.sh 中找到这个文件。在windows中,你需要将export改为set。在不同的 shell(如果不是 bash)中,您需要按照说明进行操作。