Reputation: 47
I have a EC2 instance which runs node js Servers but when autoscalling I want the newly generated instance to run the node Server .What can I do to make sure instances run the node server on boot
I have tried to use forever but I am not sure how to use it.Is there any way i can use cronjob to do this As of now i installed npm install forever -g and installed forever-monitor in my directory where Server.js is running
const http = require('http');
const app = require('./app');
var accesslog = require('access-log');
const port = process.env.PORT || 9000;
const server = http.createServer(app);
server.listen(port);
Upvotes: 0
Views: 145
Reputation: 1690
Create an AMI that has your script as a service, by following this guide https://timleland.com/how-to-run-a-linux-program-on-startup/
Then just have your Autoscale group launches instances with that AMI
Upvotes: 1