Java Tomcat未正确启动Monit

Java Tomcat未正确启动Monit,java,tomcat,monit,Java,Tomcat,Monit,我们尝试使用以下配置的monit服务启动/停止tomcat应用程序 check process tomcat matching /opt/tomcat start program = "/usr/bin/env APP_ENCRYPTION_PASSWORD=Password /opt/tomcat/bin/startup.sh" as uid "tomcat" and gid "tomcat" stop program = &

我们尝试使用以下配置的monit服务启动/停止tomcat应用程序

check process tomcat matching /opt/tomcat
  start program = "/usr/bin/env APP_ENCRYPTION_PASSWORD=Password /opt/tomcat/bin/startup.sh" as uid "tomcat" and gid "tomcat"
  stop program = "/usr/bin/env APP_ENCRYPTION_PASSWORD=Password /opt/tomcat/bin/shutdown.sh" as uid "tomcat" and gid "tomcat"
  if not exist
    then alert
  if changed pid
    then alert
  if 3 restarts within 3 cycles
    then alert
  if not exist
    then start
tomcat应用程序已启动,但某些功能不起作用。 功能说明:从UI中,如果单击某个按钮,将在特定路径上创建zip文件。 当我试图用monit启动tomcat时,上述功能不起作用,但当我用startup.sh启动tomcat时,同样的功能也起作用

以下是错误:

   Caused by: java.io.FileNotFoundException: DirectorRegister_5af97d34e4b0b0d7d7bb22c0_1601470611272.xlsx (Permission denied)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
    at com.tarento.framework.util.RegisterExcelUtil.downloadRegisterData(RegisterExcelUtil.java:193)
    at com.tarento.framework.util.RegisterExcelUtil$$FastClassBySpringCGLIB$$e02e1bec.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
原因:java.io.FileNotFoundException:DirectorRegister_5af97d34e4b0b0d7d7bb22c0_1601470611272.xlsx(权限被拒绝)
位于java.io.FileOutputStream.open0(本机方法)
在java.io.FileOutputStream.open(FileOutputStream.java:270)
位于java.io.FileOutputStream。(FileOutputStream.java:213)
位于java.io.FileOutputStream。(FileOutputStream.java:162)
位于com.tarento.framework.util.RegisterExcelateDil.downloadRegisterData(registerExcelateDil.java:193)
在com.tarento.framework.util.RegisterExcelateTil$$FastClassBySpringCGLIB$$e02e1bec.invoke()上
位于org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
位于org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
在org.springframework.aop.framework.ReflectiveMethodInvocation.procedue(ReflectiveMethodInvocation.java:157)上

这里有很多帮助。

从终端运行脚本和通过monit运行脚本之间应该只有一个主要区别:monit不会创建任何环境。因此,启动和关闭脚本可用的唯一环境变量是
APP\u ENCRYPTION\u PASSWORD
。您可以尝试
bash-c'/usr/bin/env APP\u ENCRYPTION\u PASSWORD=PASSWORD/opt/tomcat/bin/startup.sh'