EC2 Linux实例启动时启动程序
我有一个用 C# 编写的程序,希望它在我的实例启动时启动。
我已经将“mono /home/ec2-user/program/program.exe”添加到 /etc/rc.local 但它什么也没做。 我必须做什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
考虑使用 cloud-init (如果您使用的是 Ubuntu),或 用户数据启动脚本。这些将允许您启动一个实例,按照您喜欢的方式配置它(使用必要的包,如 mono),下载您自己的代码,并在实例启动后立即运行它。
这是重用实例或重新打包实例的首选方法,因为将“库存”图像转换为您自己的自定义图像所需的所有步骤都是自动化的。
Consider using 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.
据我所知,关于实例重新启动时发生的情况,@vsekhar 是正确的。在这种情况下,守护进程是最好的选择。
然而,由于 RAM 中的所有信息都会丢失,因此通常只需重新启动即可。您可以启动实例并重新启动,以便正常处理启动脚本。对于重新启动,您可以使用
ec2-reboot-instances
。@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
.