Skip to content

Microsoft.Garnet package: Server Initialization Fails with just --help, missing log message #817

@zachrybaker

Description

@zachrybaker

Describe the bug

only some options seem to boot. --port for example. But specifying others fails, in a not-helpful way.

--help, for example, will show you the help options, then crash in the constructor. It will show:
07::09::39 info: ArgParser[0] Configuration import from embedded resource succeeded. Path: defaults.conf.
Unhandled exception. Garnet.common.GarnetException: Encountered an error when initializing Garnet server. Please see log messages above for more details.
at Garnet.GarnetServer..ctor(String[] commandLineArgs, ILoggerFactory loggerFactory, Boolean cleanupDir, IAuthenticationSettings authenticationSettingsOverride)
at GarnetStart.Program.Main(String[] args) in C:\SEA\SmallProjects\Garnet\GarnetStart\GarnetStart\Program.cs:line 10
at GarnetStart.Program.

(String[] args)

We believe this issue, whatever it is, might be what is not allowing us to feed it our garnet.conf file via the option when running as service - but it may not, it's really hard to tell!

Steps to reproduce the bug

Create console .net8.0 project

add Microsoft.Garnett (any recent version, 1.0.39 for example)

change main method:

 static async Task Main(string[] args)
 {
     using var server = new Garnet.GarnetServer(args);
     server.Start();
     await Task.Delay(Timeout.Infinite);
 }

Start project (fine)
Start from command line (fine)
Start from command line with --help option (display help, then crash)

Expected behavior

show help info, then quit gracefully, or keep running.

Screenshots

07::25::05 info: ArgParser[0] Configuration import from embedded resource succeeded. Path: defaults.conf.
Unhandled exception. Garnet.common.GarnetException: Encountered an error when initializing Garnet server. Please see log messages above for more details.
at Garnet.GarnetServer..ctor(String[] commandLineArgs, ILoggerFactory loggerFactory, Boolean cleanupDir, IAuthenticationSettings authenticationSettingsOverride)
at GarnetStart.Program.Main(String[] args) in C:\SEA\SmallProjects\Garnet\GarnetStart\GarnetStart\Program.cs:line 10
at GarnetStart.Program.

(String[] args)

Release version

1.0.39

IDE

Visual Studio 2022
command line
Windows service

OS version

Windows 10
Windows server 20xx

Additional context

My end game is to get it up as a BackgroundService-ified version of the service as a windows service a la:

sc config "Famis Web PubSub" binPath="D:\AppsSvc\FamisPubSubService\FamisPubSubService.exe --config-import-path D:\AppsSvc\FamisPubSubService\garnet.conf"

seem to get more or less the same unspecified error in constructor, This does work on command line, so...odd:

FamisPubSubService.exe --config-import-path D:\AppsSvc\FamisPubSubService\garnet.conf

I think I'll be able to solve that, once the issue that prevents construction with just the --help option is sorted, and the missing log message shows up.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions