简体   繁体   English

在pm2或类似服务器上运行噩梦

[英]Run nightmare by pm2 or something like that on the server

如何通过pm2或类似服务器上的东西运行nightmarejs ,因为噩梦现在使用电子和电子需求图形,所以我现在使用xvfb-run npm start ,但是此解决方案需要我通过ssh保持与服务器的连接才能拥有有什么建议吗?

Use "screen". 使用“屏幕”。 "Screen is a console application that allows you to use multiple terminal sessions within one window. The program operates within a shell session and acts as a container and manager for other terminal sessions, similar to how a window manager manages windows." “ Screen是一个控制台应用程序,允许您在一个窗口中使用多个终端会话。该程序在Shell会话中运行,并充当其他终端会话的容器和管理器,类似于窗口管理器管理窗口的方式。” (ref: info ) (参考: 信息

apt-get install screen

# Create a session called "my_app"
screen -S my_app

# Now you are inside another shell
xvfb-run npm start

# After that, you can detach the screen or close the connection

When you want to connect again to the screen, you must use reattach option -r . 要再次连接到屏幕时,必须使用重新连接选项-r

screen -r my_app

To list active screens: 列出活动屏幕:

screen -ls

More options and info about screen command: 有关screen命令的更多选项和信息:

https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/ https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/

Is kind off old but here my answer might be help someone. 有点旧,但在这里我的回答可能是帮助某人。

  1. Create a execution file for pm2 (process.json) with the next. 接下来,为pm2(process.json)创建一个执行文件。 Substituting for your specific case. 替代您的特定情况。
{
  "apps" : [{
    "name"        : "<your_app_name>",
    "script"      : "<your_main.js>",
    "env": {
      "DISPLAY": ":99"
    }
  },
    {
      "name"        : "Xvfb",
      "interpreter" : "none",
      "script"      : "Xvfb",
      "args"        : ":99"
    }]
}
  1. Move this file to your dist folder or where your main files is stored. 将此文件移到dist文件夹或主文件存储位置。
  2. Execute pm2 start process.json . 执行pm2 start process.json

You should see both projects executing. 您应该看到两个项目都在执行。

For futher information you can follow this 有关更多信息,您可以按照

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

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