Starting Windows service automatically at Windows startup that is dependent on Oracle Starting Windows service automatically at Windows startup that is dependent on Oracle windows windows

Starting Windows service automatically at Windows startup that is dependent on Oracle


Remember, the code for your service's startup should do as little as possible. In other words, don't have your service startup check for availability of the Oracle server, or indeed do anything. Have your service do the following:

  • Log the fact that it's started
  • Load any applicable configuration from config files/registry/etc
  • Spin-up a thread that will try and "startup" the service properly every N seconds, and will repeat M times until it gives up. Have N and M configurable from your config file/registry

Have the thread "try" to connect to the applicable Oracle server and if it fails, go to sleep for N seconds, and do this M times. If it succeeds it can then start doing the "meat" of what it's supposed to.

Ironically, it's probably the fact that the Oracle service does something similar to what I've proposed you do that's causing you the problem. By returning "Yes, I've started" quickly back to Windows when it's started, it allows your service to then be loaded, even though Oracle is still busy spinning stuff up. Ideally in this scenario rather than rejecting your requests, Oracle should enqueue them for processing when it is ready.