简体   繁体   English

如何仅在AWS EC2自动缩放组中的一个tomcat实例中启动Web流程

[英]How to start a web process in only one tomcat instance in AWS EC2 autoscaling group

I have a REST web application running in AWS ec2 cloud. 我有一个在AWS ec2云中运行的REST Web应用程序。 I want to ensure that a web process is only started in only one of the tomcat instances in AWS autoscaling group. 我想确保仅在AWS自动缩放组中的一个tomcat实例中启动一个Web进程。 What is the best way to implement this? 实现此目的的最佳方法是什么? I am looking for something like a cloud-wise semaphore or lock that can be acquired and flagged appropriately by a tomcat instance so as to prevent the process from being started again by other tomcat instances. 我正在寻找可以由tomcat实例适当获取和标记的云计算信号或锁之类的东西,以防止其他tomcat实例再次启动该过程。 Thanks in advance. 提前致谢。

Not sure what you're trying to accomplish, but there are probably better ways to do it. 不知道您要完成什么,但是可能有更好的方法来实现。

I think I'd push details of your job into an SES queue, and have all of your instances poll the queue. 我想我会将您的工作详细信息推送到SES队列中,并让所有实例轮询该队列。 When there's work to do, one of them can grab the item from SES, do the work, and delete the item when complete. 当有工作要做时,其中一个可以从SES中获取项目,进行工作,并在完成后将其删除。

If you're trying to achieve cron-like functionality, look at scheduled tasks in Lambda - you can run java code, so you don't need to run a server. 如果您要实现类似cron的功能,请查看Lambda中的计划任务-您可以运行Java代码,因此无需运行服务器。

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

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