سؤال

I've created a bare-bones NServiceBus endpoint (which doesn't do anything for now), and when I install it (using NServiceBus.Host.exe /install /displayName:"MyEndpoint"), it gets installed as a service that runs under Local Service, and it works perfectly.

Now, when I change the Run as account for this Windows Service to my own local service account (lets call it "svcTestAccount" for now, it has Logon as a service permission), the service starts and then unexpectedly stops halfway during its initialization.

I can't tell why, since no exceptions get logged to log4net, the process just terminates. I've seen this behaviour before in a previous project when the endpoint couldn't access the queue it needed, but this time I have configured the 5 queues that my endpoint to give "Everyone" "Full Control", so it shouldn't be that, right?

What's strange is that, when I run it (using the NServiceBus.Host.exe on production profile), it happily runs in all the following situations:

  • From within Visual Studio 2012, running as local admin.
  • As a windows service, running under Local Service
  • As a windows service, running under Network Service
  • As a windows service, running under svcTestAccount, if svcTestAccount is a member of the local Administrators group.
  • From a command prompt running under svcTestAccount (i.e. "runas /user:svcTestAccount cmd" to open the command prompt, then NServiceBus.Host.exe to run my endpoint)

The only thing that doesn't work is getting it to run as a Windows Service under svcTestAccount (and not being a member of the local Administrators group).

Can anybody tell me what's going on?

For completeness sake, my endpoint only consists of:

public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
    public void Init()
    {
        Configure.With()
            .DefaultBuilder()
            .Log4Net();
    }
}

And my web.config:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<configuration>
  <configSections>
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
  </configSections>

  <UnicastBusConfig>
    <MessageEndpointMappings>

    </MessageEndpointMappings>
  </UnicastBusConfig>
</configuration>

I'm using NServiceBus 4.3.0 on Windows Server 2012.

هل كانت مفيدة؟

المحلول

To run NServiceBus host as a different account (not Local System) you need to execute the installer with /username and /password, eg:

NServiceBus.Host.exe /install /displayName:"MyEndpoint" /username:"mydomain\username" /password:"mysecretpassword"

See http://docs.particular.net/NServiceBus/the-nservicebus-host#installation for more info.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top