如何在 Windows Azure 上启动 WebCgiRole 时执行页面或应用程序
当 WebCgiRole 在 Windows Azure 上启动时,如何执行 PHP 页面或应用程序?
How can I execute a PHP page or an application when WebCgiRole starts on Windows Azure?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行启动任务有两种方法。 “老派”方法是将任务包含在角色的 OnStart 方法中。这可以通过将功能嵌入到 RoleEntryPoint 的 OnStart 中或通过 shell 运行批处理文件或 powershell 脚本来完成。然而,这种方法要求您能够对本质上是 .NET 托管代码类进行更改。在您基于 php 的环境中,这可能不是最佳的。
第二种方法是通过 PDC10 上发布的 1.3 SDK 版本提供的新方法。它使用通过服务配置提供的新启动任务。开发团队成员 Wade Wegner 有一篇不错的博客文章讨论了如何使用此功能。简而言之,使用它您可以运行那些启动批处理或 powershell 命令,而无需修改托管代码中的 OnStart 事件。
http://www.wadewegner.com/category/startup-task/
现在您面临的挑战可能是您的启动任务是在 PHP 脚本中定义的。不幸的是,我找不到任何可靠的例子,而且我的 PHP 技能也确实非常有限。但这或许还是可行的。希望韦德博客上的信息至少足以让您朝着正确的方向前进。 :)
There are two methods of executing startup tasks. The "old school" method was to include the task as part of the role's OnStart method. This could be done either by imbedding the functionality into the RoleEntryPoint's OnStart or by shelling out to run a batch file or powershell script. However, this approach requires you to be able to make alterations to what's essentially a .NET managed code class. Something that may not be optimal in your php based environment.
The second approach is a new one that's available via the 1.3 SDK releast that came out at PDC10. Its using the new start-up tasks that are available via the service configuration. Wade Wegner, a member of the development team, has a nice blog post that discusses using this feature. In a nuthsell, with it you can then run those start-up batch or powershell commands without having to modify the OnStart event in managed code.
http://www.wadewegner.com/category/startup-task/
Now the challenge for you may be that your start-up task is defined in a PHP script. Unfortunately, I couldn't find any solid examples for this and my PHP skills are admittedly pretty limited. But it might yet be do-able. Hopefully the information at Wade's blog will at least be enough to get you going in the right directino. :)