feat(installer): harden database init and service setup steps
- InitDatabaseStep: create DbPath parent directory so custom paths work - RegisterServiceStep: pass obj= argument so ServiceAccount is honoured - StartServiceStep: poll for RUNNING state so downstream steps don't race
This commit is contained in:
@@ -43,13 +43,21 @@ public sealed class RegisterServiceStep : IInstallStep
|
||||
|
||||
// Create service
|
||||
var startType = ctx.AutoStart ? "auto" : "demand";
|
||||
var createArgs = $"create {ServiceName} binPath= \"{workerExe}\" start= {startType}";
|
||||
|
||||
if (ctx.ServiceAccount == "CurrentUser")
|
||||
return StepResult.Fail(
|
||||
"Service cannot run as Current User without a password. " +
|
||||
"Select 'Local System' or extend ServicePage to capture a password.");
|
||||
|
||||
var objArg = ctx.ServiceAccount switch
|
||||
{
|
||||
"LocalSystem" => " obj= LocalSystem",
|
||||
"NetworkService" => " obj= \"NT AUTHORITY\\NetworkService\"",
|
||||
"LocalService" => " obj= \"NT AUTHORITY\\LocalService\"",
|
||||
_ => "",
|
||||
};
|
||||
var createArgs = $"create {ServiceName} binPath= \"{workerExe}\" start= {startType}{objArg}";
|
||||
|
||||
progress.Report("Creating service...");
|
||||
var (exitCode, output) = await RunSc(createArgs, ctx, progress, ct);
|
||||
if (exitCode == 1072)
|
||||
|
||||
Reference in New Issue
Block a user