天青:如何执行启动任务延迟? [英] Azure: How to execute a startup task delayed?

查看:293
本文介绍了天青:如何执行启动任务延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的WebRole内的两个站点和定义启动任务。

I have two Sites within my WebRole and have defined a Startup task.

第一行正常工作,它为我创建一个新的应用程序池:

The first line works fine, it creates a new App pool for me:

%WINDIR%\system32\inetsrv\appcmd.exe add apppool /name:"VCPool" /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"

现在,我想我的第二次​​改变这个新创建的应用程序池,但之后加入另一行,并没有帮助。

Now I would like to change my second to this new created AppPool, but adding another line right after, doesn't help.

%WINDIR%\system32\inetsrv\appcmd.exe set app "WebRole_IN_0_VC/" /applicationPool:"VCPool"

看来第二个站点在某种程度上还没有准备好。

It seems the second site is somehow not yet ready.

我怎么能30秒延时我的任务或Appcmd.exe的延迟稍微?
除非是创建这个启动任务相关的方式,当第二个站点启动并运行它仅应执行?

How can I delay my task by 30 seconds or delay appcmd.exe slightly? Unless there is a way to create dependencies for this startup task that it shall only be executed when that second site is up and running?

任何帮助将是非常美联社preciated,
非常感谢,

Any help would be highly appreciated, Many Thanks,

有没有拖延这一执行了30秒,确保第二个站点启动并可以改变的方式?

Is there a way to delay this execution by 30 seconds to make sure the second site is up and can be changed?

更新:

谢谢你的提示。我做了进一步调查此事。我发现的OnStart()事件。

Thanks for the hints. I have made further investigation into this matter. I have found OnStart() event.

1),但自从我使用Silverlight和简单的包裹在云中的角色项目现有的Web项目,我不会有WebRole.cs这样。可我只是把它添加到我的Silverlight Web项目并使用它呢?或者是建议从头开始创建WebRole项目,并使其产品总数取代的Silverlight Web项目?

1) But since I am using silverlight and simply wrap the existing Web project in the Cloud Roles project, I wouldn't have a WebRole.cs as such. Can I just add it to my Silverlight Web project and use it there? Or is it recommended creating a WebRole project from scratch and make it to replace the Silverlight Web project alltogether?

2)关于<运行时间/> 在服务定义标签,我只需添加像这样?难道有任何安全问题时,webrole运行高架?

2) Regarding the <Runtime/> tag in the service definition, do I simply add it like this? Would it have any security implications when the webrole runs elevated?

<WebRole name="WebRole" enableNativeCodeExecution="true" vmsize="ExtraSmall">
    <Runtime executionContext="elevated"/>
    <Sites>
      <Site name="WebRole" physicalDirectory="./WebRole">
      ...
    </Sites>
</WebRole>

3)最后但并非最不重要我怎么运行CMD文件或实际上这行

3) Last but not least how do I run a cmd file or in fact this line

%WINDIR%\system32\inetsrv\appcmd.exe set site /site.name:"WebRole_IN_0_VC" /[Path='/'].applicationPool:"ASP.NET v4.0" >>Log.txt

在的OnStart()方法?

in the OnStart() method?

推荐答案

您可以探索使用PowerShell脚本来执行这些任务。 PowerShell有一个办法睡觉线程。类似

Can you explore using PowerShell scripts for performing these tasks. PowerShell has a way to sleep thread. Something like

批处理文件

%WINDIR%\system32\inetsrv\appcmd.exe add apppool /name:"VCPool" /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"
powershell -command "Set-ExecutionPolicy Unrestricted" 2>> err.out 
powershell .\sleep.ps1 2>> err.out
%WINDIR%\system32\inetsrv\appcmd.exe set app "WebRole_IN_0_VC/" /applicationPool:"VCPool"

我还没有试过,但它应该工作。看到这个<一个href=\"http://blogs.msdn.com/b/jimoneil/archive/2011/02/07/azure-startup-tasks-and-powershell-lessons-learned.aspx\"相对=nofollow>帖子了解PowerShell的集成。

I have not tried but it should work. See this post to know about Powershell integration.

这篇关于天青:如何执行启动任务延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆