Restarting Azure Worker role “WaWorkerHost.exe” manually

后端 未结 2 454
攒了一身酷
攒了一身酷 2021-02-09 08:24

As I understand Azure Worker roles run by the help of Host application called WaWorkerHost.exe and there is another application called WaHostBootstrappe

相关标签:
2条回答
  • 2021-02-09 09:11
    1. The bootstrapper checks the WaWorkerHost status every 1 second.
      You can see it in the bootsrapper logs (c:\resources\WaHostBootstrapper.txt), by looking at interval of the trace:

    "Getting status from client WaWorkerHost.exe"


    1. You can use AzureTools which is a utility used by Azure support team.

    One of the its features is gracefully recycle the role instance:

    Alternatively, you can restart the instance programmatically:

    • Upload management certificate to your subscription.
    • Use the following code to programmatically restart the instance:

    Using Microsoft Azure Compute Management library:

    X509Certificate2 cert = new X509Certificate2("");
    var credentials = new CertificateCloudCredentials("your_subscription_id", cert);
    
    using (var managementClient = new ComputeManagementClient(credentials))
    {
        OperationStatusResponse response =
            await managementClient.Deployments.RebootRoleInstanceByDeploymentSlotAsync(
                "cloud_service_name",
                DeploymentSlot.Production, // or staging
                "instance_name");
    }
    

    1. This is not recommended, for three reasons:

      1. The bootsrapper checks every second, which should be enough for most cases.
      2. It could lead to weird issues. For example, you kill the worker, bootstrapper identifies that the worker is down, you manually start the worker, bootstrapper also tries to start the worker and fail (will crash? will enter zombie state?). It can lead to unhealthy bootstrapper, means that nothing takes care of the worker process.
      3. It depends, of course, on what's the bootstrapper does other than starting the worker. But even if it is currently does nothing other than starting the role, you cannot know for sure if tomorrow Azure team will decide to add it more responsibilities/actions.
    0 讨论(0)
  • 2021-02-09 09:16

    If the role itself is aware that it needs to restart, it can call RoleEnvironment.RequestRecycle to cause the role instance to be restarted.

    0 讨论(0)
提交回复
热议问题