简体   繁体   English

保持Maven / jetty应用在GCE上永久运行

[英]Keeping a Maven/jetty app running permanently on GCE

I have created a VM instance on Google Cloud Ploutform, Compute engine. 我已经在Google Cloud Ploutform Compute引擎上创建了一个VM实例。 Installed Ubunutu 18.04 LTS, Java JDK, Maven and Jetty. 已安装Ubunutu 18.04 LTS,Java JDK,Maven和Jetty。 Also installed Tomcat, but not using that at the mo. 还安装了Tomcat,但没有立即使用它。

I set the JAVA_HOME to the JDK location and added it to /etc/enviroment and confirmed this with source /etc/enviroment. 我将JAVA_HOME设置为JDK位置,并将其添加到/ etc / enviroment中,并通过/ etc / enviroment源进行了确认。 Then I CD into my app run mnv jetty:run and the app comes up on port 8888 and everything works great. 然后,我进入应用程序CD并运行mnv jetty:run,该应用程序在端口8888上启动,一切正常。

Im using the GCE Browser SSH terminal and I have two problems. 我正在使用GCE浏览器SSH终端,但有两个问题。 When I close my laptop or shut the browser the app terminates and goes down. 当我关闭笔记本电脑或关闭浏览器时,该应用程序终止并关闭。 So I have to SSH back into GCE and run the above command but firstly it tells me that my java home is pointing to jre not JDK. 因此,我必须通过SSH返回GCE并运行上述命令,但首先它告诉我我的Java主页指向的是jre而不是JDK。 Running echo JAVA_HOME shows its correct, so I need to run source /etc/environment before mvn jetty:run each time I log in. 运行echo JAVA_HOME显示其正确,因此我需要在mvn jetty之前运行源/ etc / environment:每次登录时运行。

1, How do I make the app stay open so its not reliant on a open terminal on my PC (happy to leave one open and running on the machine just not sure how to do this). 1,如何使应用保持打开状态,以使其不依赖于PC上打开的终端(高兴地让一个打开并在计算机上运行只是不确定如何执行此操作)。

2, Why do I have to run a source each time I log in? 2,为什么每次登录都必须运行源代码? Surely having it set in the environment file is enough? 在环境文件中设置它肯定够了吗?

Im a bit of a newb on java and linux so any help/advice appreciated. 我在Java和Linux上有点新手,所以任何帮助/建议都值得赞赏。

Paul 保罗

  1. You can run your app in the background so that even if you close the terminal it will not affect the java process. 您可以在后台运行应用程序,以便即使关闭终端也不会影响Java进程。 You can use this command 您可以使用此命令

    $ nohup mvn jetty:run & $ nohup mvn jetty:运行&

You logs will be redirected to a file called nohup.out in the same directory 您的日志将重定向到同一目录中的名为nohup.out的文件

  1. For setting the env variables there is one file called /etc/profile. 为了设置env变量,有一个名为/ etc / profile的文件。 Just mention the details in this file and login/logout, it will be permanent. 只需在此文件和登录/注销中提及详细信息,它将是永久的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM