gpt4 book ai didi

nginx - 玩! 1.2.4 + Nginx 负载均衡器 - 无法让两个实例在 PROD 模式下协同工作

转载 作者:行者123 更新时间:2023-12-02 08:03:34 25 4
gpt4 key购买 nike

我已经实现了 Play!我的服务器中包含两个不同实例(假设为 %inst1 和 %inst2)的应用程序,以避免在预编译任何更新时出现停机。我已经配置了 nginx 以获得负载均衡器。对于每个实例,我都有自己的子目录,并且已正确配置文件 application.conf 以获得 %inst1 和 %inst2 的不同端口。 nginx的配置文件是这样的:

upstream myapp {
server localhost:9031;
server localhost:9032;
}

server {
server_name www.example.com;

access_log /var/log/nginx/myapp.access.log;

location / {
proxy_pass http://myapp;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}

当我在开发模式下尝试此配置时,它工作得很好。我执行这两个实例,每当我停止其中一个实例以更新它时,所有流量都会流向另一个实例,而不会造成任何停机。当我再次重新启动应用程序并重新加载 nginx 时,两个实例都运行良好。

当我将实例配置为生产模式时,出现此问题。我只更改 application.conf:

%inst1.application.mode=dev
%inst2.application.mode=dev

至:

%inst1.application.mode=prod
%inst2.application.mode=prod

然后我无法让两个实例同时工作两次。每当我启动第二个时,我都会收到 502 Bad Gateway 错误。然后我检查第一个实例的状态,并收到以下错误:

$ play status --%inst1
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.2.4, http://www.playframework.org
~ framework ID is inst1
~
~ Cannot contact the application...
~

此外,我无法启动它并出现如下错误:

Oops. /usr/share/apps/klingstore1 is already started! (or delete /usr/share/apps/klingstore1/server.pid)

也不要停止:

Play was not running (Process id 11657 not found)

而且我必须手动删除 server.pid。然后我再次启动它,并且在另一个实例中再次发生这种情况。

你有什么线索吗?

谢谢!!

已解决:

最后,这似乎只是 RAM 的问题。这些实例可以在相同的 Play 配置下正常工作!和 Nginx 在几天内都没有出现问题。

最佳答案

您应该检查您的logs/system.log 文件,看看是否有一些异常阻止您的play 应用程序启动

关于nginx - 玩! 1.2.4 + Nginx 负载均衡器 - 无法让两个实例在 PROD 模式下协同工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11199263/

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