简体   繁体   中英

Windows service OnStart not called on AWS EC2

I have a windows service developed in C#.NET. It is installed on an AWS EC2 instance which is associated with an Elastic Beanstalk instance.

When I install the service and start, its OnStart event called successfully, I even tried restarting the server and this time also OnStart event of the windows service called successfully. Problem is when new EC2 instance is created by the load balancer (because previous instance was down) that time my service also get started but OnStart event was not called.

I am sure that OnStart was not called because I didn't get the expected result which supposed to be there after calling OnStart event.

Please help if you have any idea.

您是否已将该服务配置为在Windows服务中自动启动?

I had a similar situation where a Windows Service configured to start automatically failed to start when the EC2 instance was booted. Subsequently it was possible to start the service manually.

I then discovered that a Windows 2012 EC2 instance has a Windows service Ec2Config (*) that performs some important actions at startup, such as mounting EBS volumes and assigning drive letters.

I configured my service to have a dependency on Ec2Config, and since then it appears to be working perfectly.

(*) The name has changed to Ec2Launch in WIndows 2016.

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