Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
375 views
in Technique[技术] by (71.8m points)

.net - Install RabbitMQ using Wix, and set node name

I'm trying to get an installer working where RabbitMQ is involved. The services and dependencies can all be installed without issue, but I'm having trouble getting it to recognize a node name that I'm setting in the system environment variables. The core issue is that the PC/host name is being changed as part of a third party deployment process, which breaks Rabbit entirely.

The system environment variable (RABBITMQ_NODENAME) is added by a simple console executable at the start of the Wix bootstrapper.

I suspect it's because the installer doesn't get the memo about the updated variables, so when the RabbitMQ installer runs later in the Wix chain it just uses the default Rabbit node name.

My latest attempt to resolve has an additional console executable at the end of the chain that runs the following commands in the Rabbit sbin/ directory in order to try to "refresh" the Rabbit installation:


FireRabbitBatchProcess("rabbitmq-service.bat", "remove");
FireRabbitBatchProcess("rabbitmq-service.bat", "install");
FireRabbitBatchProcess("rabbitmq-service.bat", "start");
...
private static void FireRabbitBatchProcess(string fileName, string arg)
{
    string rabbitScriptsPath = @"C:Program FilesRabbitMQ Server
abbitmq_server-3.6.5sbin";
    string batchFilePath = Path.Combine(rabbitScriptsPath, fileName);

    if (File.Exists(batchFilePath))
    {
         TryLog("FireRabbitBatchProcess: Running " + batchFilePath + " with argument " + arg);
         Process proc = new Process { StartInfo = new ProcessStartInfo() { FileName = batchFilePath, Arguments = arg } };
         proc.Start();
         proc.WaitForExit(60 * 1000);
    }
    else
    {
         TryLog("FireRabbitBatchProcess: This batch file does not exist! " + batchFilePath);
    }
}

But this doesn't appear to work either. However, if I run those commands myself after installation it will work fine.

Is there an obvious way I'm missing that can install Rabbit and have it use a specific node name such that PC name changes don't break it?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Sounds like you need someone to implement 5981 - Burn support for WM_SETTINGSCHANGED to refresh environment variables.

For your workaround additional console executable, it is possible to query the registry for the updated environment variable and pass that onto the child process you're creating (ProcessStartInfo.Environment).

Ideally, the bundle would be the one that decides the value of that environment variable and it passes it to each package that needs that information so you don't have to rely on environment variables.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...