NPM在SSH连接之后的服务器上开始(EC2)

发布于 2025-01-24 16:18:37 字数 270 浏览 4 评论 0原文

我有一个从“ NPM启动”开始的应用程序 我想在后台运行它。 该应用程序托管在AWS EC2上。

我尝试了:

  • npm start& 如果我断开SSH连接,则不起作用

  • nohup npm start& 同样,如果我断开SSH连接

    ,它会失败
  • 同样,如果我尝试使用root或用户启动的 。

  • 我也永远尝试了

非常感谢您的帮助

I have an app that I start with "npm start"
I would like to run it in background.
This app is hosted on aws EC2.

I tried :

  • npm start &
    Doesnt work if I disconnect ssh connection

  • nohup npm start &
    Same, it fail if I disconnect ssh connection

  • I tried to launch with root, or user, doesnt make any difference.

  • I also tried forever but I didnt manage to launch with npm start like "forever start npm start" doesnt work

Thanks a lot for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

别在捏我脸啦 2025-01-31 16:18:37

您必须使用Docker。
您需要阅读很多文档,因为了解您是否不知道这很复杂: https:https: //docs.docker.com/get- started/

但它确实可以做您想要的,在容器中运行应用程序。
您可以关闭您的应用程序仍将运行的所有内容。

喜欢阅读!

You have to use docker.
You will need to read a lot the documentation, because it's complicated to understand if you dont know it : https://docs.docker.com/get-started/

But it does exactly what you want, running app in background in a container.
You can close everything your app will still run.

Enjoy reading !

2025-01-31 16:18:37

下次我会尝试Docker风格,因为我的时间没时间了。
我找到了使用:“屏幕”命令的方法

I will try the docker style next time because im running out of time.
I found a way using :

"screen" command !

是伱的 2025-01-31 16:18:37

实际上该过程在屏幕上几个小时后停止

Actually the process stop after few hours with screen

浅听莫相离 2025-01-31 16:18:37

您可以将新命令(nohup)添加到您的软件包。JSON:

  "scripts": {
    "start": "vue-cli-service serve",
    "nohup": "nohup vue-cli-service serve &"
  },

它应该复制您的start命令,但请使用nohup和&

You can add a new command (nohup) to your package.json:

  "scripts": {
    "start": "vue-cli-service serve",
    "nohup": "nohup vue-cli-service serve &"
  },

It should copy your start command, but surround it with nohup and &

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文