简体   繁体   English

在AWS Elastic Beanstalk上部署Windows服务和Web应用程序

[英]Deploying windows service and web app on AWS Elastic Beanstalk

We want to deploy an ASP.NET MVC web application and windows service to elastic beanstalk. 我们希望将ASP.NET MVC Web应用程序和Windows服务部署到弹性beanstalk。 We use awsdeploy.exe to handle the deployment of the web application. 我们使用awsdeploy.exe来处理Web应用程序的部署。 The service and the web application share a configuration and libraries. 该服务和Web应用程序共享配置和库。 To deploy the service my plan was: 为了部署服务,我的计划是:

  1. Include the windows service exe in the web deployment package \\bin directory and deploy the service and web application together 在Web部署包\\ bin目录中包含windows service exe,并将服务和Web应用程序一起部署
  2. Use an .ebextensions file to install the service 使用.ebextensions文件来安装该服务

However, this doens't seem to work as the .ebextensions actions are executed before the webdeploy package is installed so the service exe isn't available to be installed. 但是,这似乎不起作用,因为.ebextensions操作在安装webdeploy包之前执行,因此无法安装服务exe。

It seems that my options are: 看来我的选择是:

S3 S3

Zip the service exe and publish it to S3 so it is available to be installed by .ebextensions when the web application is deployed. 压缩服务exe并将其发布到S3,以便在部署Web应用程序时可以通过.ebextensions安装它。

This isn't ideal as the service and web app share dependencies + configuration. 这并不理想,因为服务和Web应用程序共享依赖关系+配置。 The service would need to be installed with a separate set of dependencies and config as it would need to be up and running before the web application can be updated. 该服务需要安装一组独立的依赖项和配置,因为它需要在Web应用程序更新之前启动并运行。

Post Deploy Scripts 部署后脚本

Use the unsupported post deployment script technique which I'd need to translate into the windows world. 使用不支持的部署后脚本技术 ,我需要将其转换为Windows世界。

Windows directory = C:\\Program Files\\Amazon\\ElasticBeanstalk\\hooks\\appdeploy\\post There is a .ps1 script file there. Windows目录= C:\\ Program Files \\ Amazon \\ ElasticBeanstalk \\ hooks \\ appdeploy \\ post那里有一个.ps1脚本文件。 (Is .cmd supported?) (支持.cmd吗?)

Use the Web Deploy Package as a .ebextensions zip source 使用Web Deploy Package作为.ebextensions zip源

We could be able to use the webdeploy package @ "C:\\cfn\\ebdata\\source_bundle.zip" as a source, unzip it and install the service from there. 我们可以使用webdeploy软件包@“C:\\ cfn \\ ebdata \\ source_bundle.zip”作为源代码,解压缩并从那里安装服务。 The problem is the internal paths in the zip are dependent on how the user's machine how built it was setup so finding the exe in the unzipped file structure would be tricky. 问题是zip中的内部路径取决于用户的机器如何构建它的设置,因此在解压缩的文件结构中找到exe会很棘手。 Example path = "Content\\C_C\\gitdeploy\\blah\\blahSolution\\blahProject\\obj\\awsTestDebug\\Package\\PackageTmp\\bin\\myservice.exe" 示例path =“Content \\ C_C \\ gitdeploy \\ blah \\ blahSolution \\ blahProject \\ _ obj \\ awsTestDebug \\ Package \\ PackageTmp \\ bin \\ myservice.exe”

Any suggestions on which approach to take? 有关采取哪种方法的任何建议?

Edit 编辑

Taking Jim's advice I used container_commands and it works nicely. 根据Jim的建议,我使用了container_commands,它运行良好。 My .ebextensions/install.config looks like this.. 我的.ebextensions / install.config看起来像这样..

...
container_commands:
  installTaskRunner:
    command: C:\\inetpub\\wwwroot\\App_Data\\installTaskRunner.cmd >> C:\\inetpub\\wwwroot\\App_Data\\installTaskRunner.log
commands:
  stop_service:
    command: net stop MyService
    ignoreErrors: true
...

The batch file looks like this... 批处理文件看起来像这样......

pushd C:\inetpub\wwwroot\bin
C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\installutil  MyService.exe
net start MyService
popd

Edit #2 编辑#2

Added additional command to instal.config to stop the service before the webdeploy package is applied as the service.exe locks some deployment files. 添加了instal.config的其他命令,以便在应用webdeploy软件包之前停止服务,因为service.exe会锁定某些部署文件。

Regarding the post deploy scripts, any file in one of those folders with a .ps1, .bat, or .exe will be run during that stage. 关于后部署脚本,其中一个文件夹中包含.ps1,.bat或.exe的文件将在该阶段运行。 This is the method to use if you require fine control over when things happen on the instance. 如果您需要对实例上发生的事情进行精细控制,则可以使用此方法。

There's a third option, which is to use container_commands: instead of commands: 还有第三种选择,即使用container_commands:而不是commands:

container_commands: will be run after the application is deployed. container_commands:将在部署应用程序后运行。

The documentation for this can be found in the Elastic Beanstalk Developer Guide . 可以在Elastic Beanstalk开发人员指南中找到相关文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Amazon Elastic Beanstalk部署.NET Windows服务而不使用Web应用程序 - Deploy a .NET Windows Service with Amazon Elastic Beanstalk with no Web Application 使用Elastic Beanstalk部署.NET worker应用程序 - Deploying a .NET worker app with Elastic Beanstalk 将简单的.NET 4.5 Web API模板部署到Elastic Beanstalk - Deploying a Simple .NET 4.5 Web API Template to Elastic Beanstalk 将MVC .NET应用程序从Visual Studio部署到AWS Elastic BeanStalk - Deploy MVC .NET app from Visual Studio to AWS Elastic BeanStalk 使用Elastic beantalk部署.net Web应用程序并连接到远程数据库 - Using elastic beanstalk to deploy .net web app and connect to remote db DefaultAppPool 在 AWS Elastic Beanstalk 上部署 ASP.NET MVC 站点后停止 - DefaultAppPool getting stopped after deploying ASP.NET MVC site on AWS Elastic Beanstalk .Net项目中的AWS Elastic Beanstalk文件夹 - AWS Elastic Beanstalk folders in a .Net project 将Windows Service集成到Web应用程序中 - Integrating windows service in a web app 使用AWS Toolkit(.Net)创建AWS Elastic Beanstalk环境时出错 - Error Creating an AWS Elastic Beanstalk Environment using AWS Toolkit (.Net) Windows服务部署问题 - Windows service deploying problem
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM