Project

General

Profile

Easy way to implement my own Configuration?

Added by Matt Russell over 8 years ago

I would like to modify how configuration is done in Wt. Rather than reading from wt_config.xml, I would like to be able to pass a configuration object to WServer or something.

It appears that I could extend http/WServer, web/WebController, and web/Configuration to get at Configuration::readApplicationSettings.. but that seems like a relatively big and hard-to-maintain change.

Is there a good way to do this?

The motivation for this change is that we have a process that manages all our other processes in a custom way, and I would like to try to fit our Wt app into this. Our process manager kicks off processes by linking against them (and calling Run()) rather than calling them with a system command; so I have no way to send command line arguments to specify the config xml file.


Replies (4)

RE: Easy way to implement my own Configuration? - Added by Saif Rehman over 8 years ago

What I've done in the past is that I used rapidxml, already packaged with Wt, to create a wt_config.xml file on program startup. Not the best way, however it works and you only have to add those config elements that you don't want as the default instead of creating a complete wt_config.xml.

The other way would be to modify Wt. As far as I know Wt doesn't allow modifying config through program.

RE: Easy way to implement my own Configuration? - Added by Saif Rehman over 8 years ago

Oh and Wt::WServer() constructor takes the configuration file name as an argument

RE: Easy way to implement my own Configuration? - Added by Matt Russell over 8 years ago

Hi Saif,

Unfortunately I only realised the third argument to WServer's constructor was a different file than the XML file config. :)

I ended up wrapping my Wt program in another app that reads all my configuration options from another file (used by my other apps) and create an **argv and a config.xml file that are passed to Wt.

So, options like docroot, approot, config, etc, are passed in via **argv, and options such as progressive-bootstrap, or any parameter, are written to the xml file that was specified in config.

Even if I had used the WT_CONFIGURATION_FILE in WServer::WServer, I still think Wt is missing a crucial ability to be easily configured. In my opinion, all the options should be configurable with function calls.

Thanks!

RE: Easy way to implement my own Configuration? - Added by Emeric Poupon over 7 years ago

Hello,

Same problem here.

Here are the possible configuration values to be read:

1/ wt httpd server dependent: docroot, approot, tls configuration, bind address

2/ wt dependent: max upload file size, meta headers, log file path, reverse proxy presence

3/ application dependent,

For now I have my own config file to handle 1/ and 3/ and:

- I generate the argc/argv of the WServer on the fly

  • I force the user to modify the wt_config.xml in order to make it work

As suggested, I could possibly generate the xml file on the fly, but that's quite annoying.

What do you Wt guys suggest?

Maybe we could just allow user defined settings in the xml configuration file?

We would ship a default xml file with just the relevant settings exposed + the new application dependent settings. It would still be necessary to generate the argc/argv parameters for the built in server though.

What do you think?

Regards,

Emeric

    (1-4/4)