I have an application that runs as a Windows service, it stores the settings of various things in a database Which is seen when the service starts. I created the service to support various types of database (SQL Server, Oracle, MySQL, etc.). Many times the end users prefer to configure the software to use SQL Server (they can modify a config file with only the connection string and restart the service). The problem is that when their machine boots up, sometimes SQL Server starts after my service, so my service errors initially start because it can not connect to the database. I know that I can specify the dependency for my service so that the Windows Service Manager should guide me before starting the appropriate service. However, I do not know when services depend on the time required (when my service is registered) because the user can change the database later.
So my question is: Is there any way for the user to manually point out the service dependencies on those databases which they are using? If not, should the proper design approach should have taken me? I have thought of trying to do something like before my service starts waiting for 30 seconds before connecting to the database, but it looks really unstable for various reasons. I have also considered trying to connect to the "lazy" database; The problem is that I need a connection when I start immediately because there are various pieces of important information in the database that need to be started for the first time in my service. Any ideas?
Dennis who is looking for you SC.exe is a command line tool that allows users to configure services You can use it for
sc [servername] command servicename [optionname = optionvalue ...]
more specifically you want to use
SC [server name] config service dependent = servicetoDependOn
here SC.EXE
Comments
Post a Comment