Relative database paths for Saga persistence not resolved when running as a Windows Service
Hi
We've uncovered a scenario whereby if you are running Saga's within the NServiceBus host with relative (file based) paths to databases (in this instance, SQLite),using the NHibernate Saga persister, the services do not resolve the database paths correctly. This leads to the service stopping, and the following error being logged (visible in the event viewer).
Description: The application requested process termination through System.Environment.FailFast(string message). Message: The following critical error was encountered by NServiceBus: Repeated failures when fetching timeouts from storage, endpoint will be terminated. NServiceBus is shutting down.
This is because the current working directory defaults to c:\windows\system32 when running as a windows service.
I have created a small project to demonstrate this issue. If you build, install and run the service, you will see that it stops running after a few minutes.
A suggestion from John Simons that as a work around we could set the current working directory somewhere within the application (EndpointConfig seemed like a good place) does work.
I have been using 4.0.3 to reproduce this problem.
Thanks
Richard
Sample project for reproduction is here -> http://db.tt/fSt0MwUW Happy to move if you want it elsewhere.
The service stopping is the intended behaviour but we could definitely look into setting the working directory accordingly. Strangely enough I thought that TopShelf should handle this for us?
Eg the log4net logfile ends up in the correct place? (https://github.com/Particular/NServiceBus/blob/develop/src/hosting/NServiceBus.Hosting.Windows/LoggingHandlers/ProductionLoggingHandler.cs#L22)
No we can't as that would be non backwards compatible!
this is a known issue when running code from a windows service. NSB should not be messing with this conventions. Also there is a know workaround so closing this