gpt4 book ai didi

google-app-engine - Spring Boot 和云部署

转载 作者:行者123 更新时间:2023-11-28 22:25:47 24 4
gpt4 key购买 nike

我目前正在使用 Spring boot 开发 REST API。我希望它部署在谷歌云(计算引擎)上。我创建了一个虚拟 linux 机器,安装了 java 8 并将我的 spring boot 应用程序放入其中。它工作正常但是:我的应用程序是一个 jar 文件(嵌入式 Tomcat)。我用这个启动它:java -jar myApp.jar它工作正常。但是当我关闭谷歌云上的 shell 时,我的应用程序不再可用。我希望我的应用程序始终可用,而不必在每次退出 shell 时都启动它。可能吗?

image of cloud shell

最佳答案

我认为这与 Unix Thread 是同一个问题.

快速回答是您的进程链接到终端。当你关闭它时,进程被杀死。如果我引用 this answer :

What nohup does, on the other hand, is to effectively separate the process from the terminal:

  • It closes standard input (the program will not be able to read any >input, even if it is run in the foreground. it is not halted, but will receive an error code or EOF).
  • It redirects standard output and standard error to the file nohup.out, so the program won't fail for writing to standard output if the terminal fails, so whatever the process writes is not lost.
  • It prevents the process from receiving a SIGHUP (thus the name).

所以,试试

nohup  java -jar myApp.jar &

关于google-app-engine - Spring Boot 和云部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45635432/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com