• Windows Azure Cloud Service (25) 使用Startup注册COM组件(下)


      《Windows Azure Platform 系列文章目录

    让我们再回顾一下Windows Azure Startup Task

    <ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
    <WebRole name="WebRole1">
    <Startup>
    <Task commandLine="Startup.cmd" executionContext="limited" taskType="simple">
    </Task>
    </Startup>
    </WebRole>
    </ServiceDefinition>

      在以上代码中,最核心的就是Startup.cmd,这个cmd可以是PowerShell scripts。在这个cmd文件中你可以执行您自己的逻辑,比如

    -  注册一个dll(regsvr32..)

    -  注册一个Windows Service (InstallUtil..)

    -  其他PowerShell scripts (比如安装其他第三方的组件,如Crystal Report)

      为什么我们需要Startup Task呢?

      我们知道,Windows Azure VM是非持久性的。在某些异常情况下(比如断电,硬件故障等),某个正常工作的Azure VM会宕机而无法正常使用。后台的Windows Azure Fabric Controller会自动把该VM上的Azure Apps迁移到同一数据中心的另外一台正常的计算节点之上,保证服务的持久性和健壮性。

      如果没有StartUp Task,那在Fabric Controller迁移之后,Azure Apps管理员不得不远程登录到新的VM上,然后手工执行regsvr32命令。否则Azure Apps无法正常运行(的确,因为在新的Azure VM上没有注册COM组件)。但这样岂不是非常麻烦:迁移之后还需要人工来注册,不能实现自动化。

      有了Startup Task功能会在系统迁移、故障恢复的时候自动执行命令,因此每次修改都是持久性的,不需要人为干预操作。

      如果大家对Startup Lifecycle (Startup 生命周期)感兴趣的,可以参考这篇文章 《Real World : Startup Lifecycle of a Windows Azure Role》http://msdn.microsoft.com/en-us/library/windowsazure/hh127476.aspx

  • 相关阅读:
    centos7安装jdk8
    centos7安装mysql5.7.31
    docker打包,运行springboot
    centos7安装docker
    ps学习记录
    Html的学习(二)
    tensorflow C++接口调用图像分类pb模型代码
    tensorflow C++接口调用目标检测pb模型代码
    ubuntu14 编译tensorflow C++ 接口
    Python opencv计算批量图片的BGR各自的均值
  • 原文地址:https://www.cnblogs.com/threestone/p/2429761.html
Copyright © 2020-2023  润新知