简体   繁体   中英

How to run a java jar file in another AWS EC2 from my EC2/Node.js application?

We have 2 EC2 machines. One is for resource management and hosts the frontend application to trigger our SWF workflow. The other is for actually running the workflow that performs the task. The SWF application logic is written in JAVA.

Now, we need to trigger the java application in the second EC2 that performs the task from the first EC2 frontend.

Is there any way to deploy a Java application "jar" in another EC2 from one EC2 on button click? Or is there a better way to do this? Basically we need one compute resource for the application frontend & the other to perform the actions.

Our application is built using the Express.js/Node.js framework.

The recomande way to trigger computation form one instance to another is to use AWS SQS. The front end will put a message to the queue and the second instance will pull the queue and perform the work descibe in the message.

Both Java and Node.js AWS sdk contains the needed elements to use SQS.

To have a EC2 instance that start real job when start up there is 2 basic aproches:

  • Create your own AMI that contains the needed element (jdk, jar) and start the process as a service (for Linux it will be a init, upstart or systemd server depending on the distribution you are using).
  • Provide a User Data script at the creation of the instance. The script will make sure every thing is install and start the needed process ( example ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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