On Monday, my boss stated how important it is for an application to be easily set up, without the need for user to define ports, address and configuration files. Confusion and havoc will ensue when we leave things to the hands of the users. Therefore, an auto-configuration logic would need to be embedded inside the app startup itself.
So, i re-read the WServer API and found out about setServerConfiguration, which is executed in main() body. It accepts the arguments passed into the command line when running the application. For example, config file location, approot, docroot, address and port.
A standard Wt application would accept the command line arguments directly and pass it to setServerConfiguration. What I did was add lines of code to check the arguments before passing it to setServerConfiguration. Of course, I added some logic during the check that will resort to or add certain default configurations if the user fails to enter any some arguments. Since there are a few applications integrated into one main program, this auto-configuration will greatly simplify things. Now freshly cloned application can be run directly without any settings. I hope this makes my boss happy.
I would also like to point out a gcc warning which i faced while trying to implementing C++ code.
warning: deprecated conversion from string constant to ‘char*’
Since setServerConfiguration accepts char **, I needed to define some default char** (string). For example:-
commandLine = "--approot";
which results in the above warning. There are a few solutions to this, as stated here. I solved it by simply casting the string literal to (char *).