AWS opsworks多个nodejs应用程序?多个、应用程序、AWS、opsworks

2023-09-11 09:16:48 作者:刺眼人格

我有一个OpsWorks Nodejs堆栈。我设置多个nodejs应用程序。现在的问题是,所有nodejs server.js脚本监听80端口亚马逊生命检查,但该端口只能由一个被使用。 我不知道如何解决这个问题。我已阅读亚马逊的文档,但无法找到解决办法。我读,我可以尝试改变部署的配方变量设置此生检查,以不同的端口,但没有奏效。任何帮助?

解决方案

我争夺这个问题了一会儿,终于找到了一个非常简单的解决方案。

端口处于部署食谱的属性设置...

的https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.10/deploy/attributes/deploy.rb

而行......

 默认的[:部署] [应用] [:nodejs] [:端口] =部署[:ssl_support]? 443:80
 

您可以使用堆栈的定制JSON,如重写此

  {
  部署 : {
    app_name_1:{
      nodejs:{
        口:80
      }
    },
    app_name_2:{
      nodejs:{
        端口:3000
      }
    }
  },
  MongoDB的:{
    ...
  }
}
 
第一天篇③ VsCode上运行第一个NodeJs 程序,配置自动重启插件 nodemon

现在在/etc/monit.d/node_web_app-.monitrc的monitrc文件应反映各自的端口,monit的应该让他们活着!

I have one OpsWorks Nodejs Stack. I setup multiple nodejs apps. The problem now is that all nodejs server.js scripts listens on port 80 for amazon life check but the port can be used only by one. I dont know how to solve this. I have read amazon documentation but could not find the solution. I read that I could try to change deploy recipe variables to set this life check to different port but it didn't work. Any help?

解决方案

I battled with this issue for a while and eventually found a very simple solution.

The port is set in the deploy cookbook's attributes...

https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.10/deploy/attributes/deploy.rb

by the line...

default[:deploy][application][:nodejs][:port] = deploy[:ssl_support] ? 443 : 80

you can override this using the stack's custom json, such as:

{
  "deploy" : {
    "app_name_1": {
      "nodejs": {
        "port": 80
      }
    },
    "app_name_2": {
      "nodejs": {
        "port": 3000
      }
    }
  },
  "mongodb" : {
    ...
  }
}

Now the monitrc files at /etc/monit.d/node_web_app-.monitrc should reflect their respective ports, and monit should keep them alive!