小编Sam*_*ppe的帖子

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

我们希望将ASP.NET MVC Web应用程序和Windows服务部署到弹性beanstalk.我们使用awsdeploy.exe来处理Web应用程序的部署.该服务和Web应用程序共享配置和库.为了部署服务,我的计划是:

  1. 在Web部署包\ bin目录中包含windows service exe,并将服务和Web应用程序一起部署
  2. 使用.ebextensions文件来安装该服务

但是,这似乎不起作用,因为.ebextensions操作在安装webdeploy包之前执行,因此无法安装服务exe.

看来我的选择是:

S3

压缩服务exe并将其发布到S3,以便在部署Web应用程序时可以通过.ebextensions安装它.

这并不理想,因为服务和Web应用程序共享依赖关系+配置.该服务需要安装一组独立的依赖项和配置,因为它需要在Web应用程序更新之前启动并运行.

部署后脚本

使用不支持的部署后脚本技术,我需要将其转换为Windows世界.

Windows目录= C:\ Program Files\Amazon\ElasticBeanstalk\hooks\appdeploy\post那里有一个.ps1脚本文件.(支持.cmd吗?)

使用Web Deploy Package作为.ebextensions zip源

我们可以使用webdeploy软件包@"C:\ cfn\ebdata\source_bundle.zip"作为源代码,解压缩并从那里安装服务.问题是zip中的内部路径取决于用户的机器如何构建它的设置,因此在解压缩的文件结构中找到exe会很棘手.示例path ="Content\C_C\gitdeploy\blah\blahSolution\blahProject\_ obj\awsTestDebug\Package\PackageTmp\bin\myservice.exe"

有关采取哪种方法的任何建议?

编辑

根据Jim的建议,我使用了container_commands,它运行良好.我的.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
...
Run Code Online (Sandbox Code Playgroud)

批处理文件看起来像这样......

pushd C:\inetpub\wwwroot\bin
C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\installutil  MyService.exe
net start MyService
popd
Run Code Online (Sandbox Code Playgroud)

编辑#2

添加了instal.config的其他命令,以便在应用webdeploy软件包之前停止服务,因为service.exe会锁定某些部署文件.

.net amazon-web-services amazon-elastic-beanstalk

11
推荐指数
1
解决办法
4043
查看次数

如何防止在事件日志中截断服务异常

我们有ac #windows服务失败,导致将错误日志消息写入Windows事件日志.错误消息包含异常信息,但它被截断,阻止我们查看关键信息.

我们如何增加写入日志消息的数据,以便我们可以看到异常的完整堆栈跟踪?

这是我们目前在事件查看器中看到的内容.

<EventData>
    <Data>Service cannot be started. System.ArgumentException: Keyword not supported: 'port'. 
 at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) 
 at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) 
 at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) 
 at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) 
 at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) 
 at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<SetConnectionString>b__1a(DbConnection t...</Data> 
    </EventData>
</Event>
Run Code Online (Sandbox Code Playgroud)

请注意,堆栈跟踪的末尾被截断为"...".

c# windows windows-services event-log

5
推荐指数
1
解决办法
702
查看次数

mysql LIKE where 带参数的子句不使用索引

在我的测试中,包含与参数比较的 LIKE 的 where 子句的 mysql select 语句不会使用索引。全表扫描完成,性能受到影响。例如

set @gp1:= 'BOB%';
select * from quote where quoteNum like @gp1; -- this is slow
Run Code Online (Sandbox Code Playgroud)

如果值是内联的,则使用索引。例如

select * from quote  where quoteNum like 'BOB%'; -- this is fast
Run Code Online (Sandbox Code Playgroud)

有没有办法强制mysql在第一个例子中使用索引?

mysql

4
推荐指数
1
解决办法
704
查看次数