views:

162

answers:

1

I'm just starting to dig into boost::program_options for the first time. I like it quite a bit. However, what I'm trying to accomplish with it doesn't seem to be something its designers have accounted for.

I want to use boost::program_options to parse both command line options as well as config files. So far so good. Additionally, though, I would like to be able to check for updated settings (say from a new config file) that could override the previously parsed settings in my variables_map.

Granted, I could do a separate parse and try to merge the two maps. Perhaps that's what I'll end up doing. I'm just wondering, though, if anyone has done anything like this before and has come up with a slick solution.

+1  A: 

Dynamically reading updted configuration files for a long running service can cause a host of other problems (like objects that were created using the original options all need to be destroyed and re-created, thus you need to track all these objects).

When a 'Long Running' service detects a change to the config file rather than re-reading the file it is usually easier to performa controlled shut-down and re-start the service from scratch.

On Linux for example long running processes (like the WebServer) are started by the initd deamon. If any of these services die the initd will automatically re-start them correctly. So if an application detects a change in its own config file then all it really needs to do is shut down. The initd will then re-start the service thus forcing the config file to be re-read.

Martin York
The common idiom in Linux daemons is for the daemon to respond to `SIGUSR1` by reloading the configuration.
greyfade
@greyfade: Yes and no. For simple daemons where doing so is trivial. For more complex daemons where state may have been propagated through the code it is sometimes simpler to just to restart.
Martin York
This is definitely good information. However, it doesn't quite answer my question. I really am required to reload some options during run-time.
Skinniest Man