如何在AWS自动重新启动节点应用弹性魔豆节点、重新启动、弹性、魔豆

2023-09-11 10:49:21 作者:白天不懂夜的黑

我用Google搜索这个问题一段时间,但找不到答案。 我的问题是,同时部署在AWS上的nodejs应用弹性魔豆服务器,我想nodejs应用程序会自动重新启动,如果应用程序崩溃。

I have googled this question for a while but can't find the answer. My question is while deploying the nodejs application on aws elastic-beanstalk servers, I want the nodejs application would be restart automatically if the application crash.

其实有很少数nodejs包已经通过命令行,如永远的支持这一点,但有没有简单的方法,从控制台管理或awscli安装这个软件包,并执行它来自动实现重启。

Actually there're few nodejs package already support this by command line, such as forever, but there's no easy way from console management or awscli to install this package and execute it to achieve restart automatically.

我想知道你是怎么解决的AWS重启问题EB?

I am wondering how do you resolve the restart issue on aws eb?

推荐答案

是的,更好的选择使用监督,但为了重新启动应用程序服务器的AWS控制台帮助或魔豆你需要把自己的处理程序命令行工具的能力目录中的弹性魔豆钩中:/ opt / elasticbeanstalk /钩/ restartappserver /颁布 钩是外壳,Python或Ruby脚本,放置在上述目录中。把supervisord重启的逻辑在这里,你将能够与管理控制台的帮助下重新启动它,AWS CLI工具(的http://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/restart-app-server.html),弹性魔豆API:(的http://docs.aws.amazon.com/elasticbeanstalk/latest/APIReference/API_RestartAppServer.html)

Yes, better option to use Supervisor, however in order to have ability to restart app server with help of aws console or beanstalk cli tools you need to put own handler to Elastic beanstalk hooks in the directory: /opt/elasticbeanstalk/hooks/restartappserver/enact Hook is shell, python or ruby script that placed in mentioned directory. Put logic of the supervisord restart here and you will be able to restart it with help of management console, aws cli tools (http://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/restart-app-server.html), elastic beanstalk api: (http://docs.aws.amazon.com/elasticbeanstalk/latest/APIReference/API_RestartAppServer.html)

如何添加钩,安装supervisiord等,你可以在这里阅读:的http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

How to add hook, install supervisiord etc you can read here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html