iniciar un programa cuando se inicie la instancia de linux EC2

I have a program written in c# and want it to start when my instance start.

I already added "mono /home/ec2-user/program/program.exe" to /etc/rc.local but it does nothing. What do I have to do?

preguntado el 27 de agosto de 11 a las 14:08

2 Respuestas

Considera usar cloud-init (if you are using Ubuntu), or a user-data start script. These will allow you to start an instance, configure it how you like (with necessary packages like mono), download your own code, and have it run as soon as the instance starts.

This is a preferred way to re-using instances or repackaging instances since all the steps needed to transform a 'stock' image to your own customized one is automated.

Respondido 27 ago 11, 18:08

what i've read... is that cloud-init and user-data start script is for ec2-run-instance... i'm using ec2-start-instance right now... is it possible for start instance? - proyecto de ley

Generalmente no. ec2-run-instance boots up a fresh instance. ec2-start-instance hojas de vida an existing (but stopped) instance at whatever point the instance was at when it was stopped. While there's lots of ways of getting instances to do things when they first boot, there aren't so many ways to get instances to do things when they are started. Consider writing your code as a daemon that always runs, then it will be stopped and started with the instance as you expect. - vsekhar

@vsekhar is correct, as far as I am aware, regarding what happens when the instance is restarted. In that case, a daemon is about the best that can be done.

However, as all information in RAM is lost, it is often okay to just reboot. You can start the instance and reboot, allowing for normal processing of startup scripts. For rebooting, you can use ec2-reboot-instances.

Respondido el 05 de Septiembre de 11 a las 20:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.