Change config values on a specific time

461 Views Asked by At

I just got a mail saying that I have to change a config value at 2009-09-01 (new taxes). Our normal approach for this would be to to awake at 2009-08-31 at 23:59 and then just change the value manually. Which not is a big problem since this don't happens to often. But it makes me wonder how other people handle issues like this.

So! How do you handle date specific config changes?

(We are working in asp.net but I don't think this has to be language specific)

Br
Carl Bergquist

9

There are 9 best solutions below

4
pjp On BEST ANSWER

I'd normally store this kind of data in a database table like this

Key,  Value,  EffectiveFrom,  EffectiveTo
-----------------------------------------
VAT,    15.0,      20081201,     20091231
VAT,    17.5,      20100101,         NULL

I'd then use the EffectiveFrom and EffectiveTo dates to chose the value that is effective at the given time. If the rate is open ended then the effecive to could either by NULL or 99991231.

This also allows you to go back without having to change the config. E.g. if someone asks you to recalculate the tax for the previous month before the rate change.

1
sud03r On

In linux, there is a command "at" for batch execution.
See "man at" for details.

0
StampedeXV On

That depends totally on the situation and the technology.

pjp's idea is good, if you get your config from a database, or as metadata to define the valid time for whole config sets/files.

Another might be: just prepare a new configfile with the new entries and swap them at midnight (probably with a restart of the service/program) whatever. Swapping them would be possible with at (as given bei Neeraj) ...

If timing is a problem you should handle the change, or at least the timing of the change on the running server (to avoid time out of synch problems).

3
Tollo On

To be honest, waking up near the time and changing it seems to be the simplest and cheapest approach. All of the technical solutions are fine, but it depends where you work.

In our environment it would be cheaper and simpler to get someone to wake up and make the change than to redevelop the functionality of a piece of software that already works. It certainly involves less testing, development overhead and costs which means we would tend to solve the problem as you do, manually.

0
User1 On

I've seen the hybrid approach. Instead of actually changing the data model to include EffectiveDate/EndDate or manually changing the values yourself, schedule a script to change the values automatically. Also, be sure to have a solid test plan that will validate all changes.

However, this type of manual change can have a dramatic impact on reporting. If previous transactions join directly to the tables being changed, numbers in historical reports could change in a very bad way. There really is no "right" answer.

0
RameshVel On

We got same kind of problem some time before and handled using the following approach. this is suitable if you are well known to the source that orginates the configuration changes..

In our case, the source exposed a webservice (actualy a third party) which will return a modified config details. And there is a windows service running on our server which keeps on polling the webservice and will update the configuration file if there is any change.

this works perfectly in our case..

You can make use of this approach by changing the polling webservice part to your source of config change (say reading changes from some disk path). But am not sure how this is possible reading config changes from email.

0
MartW On

If I'm not able to do something like pjp's solution, I'd use either a scheduled task or a server job to update it automatically at the right time. But...I'd probably still be awake checking it had worked.

2
Phill Pafford On

Why not just make a shell script to swap out the files. run it in cron and switch the files out a minute before and send an alert text if NOT successful and an email if successful.

This is an example on a Linux box but I think you get the point and can do this on a Windows box.

Script:

cp /path/to/old/config /path/to/backup/dir/config.timestamp
cp /path/to/new/config

if(/path/to/new/config exsits) {
 sendSuccessEmail();
} else {
 sendPanicTextAlert();
}

cron:

59 23 31 8 *  /path/to/script.sh

you could test this as well before hand just point to some dummy directories and file

0
Gineer On

Look the best solution would be to parameterise your config file and add things like when a certain entry should be used from. This would negate the need for any copying or swapping of files and your application would simply deal with it. (That goes for a config file approach or a database)

If you cannot change the current systems and you have to go with swapping the config files, then you also have two options:

  1. Use a scheduled task to kick off a batch job or even a VBScript or PowerShell script (which ever you feel comfortable with) Make sure you set up the correct credentials to be able to do this at the middle of the night and you could also add some checking and mitigation into this approach.
  2. Write a windows Service that does this for you. Here you have all the flexibility you need. Code it to do whatever it needs to do, do all the checks you need to (so that you can keep sleeping rather than making sure it actually worked) etc, etc. You service would then even take care of the scheduling aspect and all will be good. Here you could use xml DOM object and xPath and not replace the file, but simply update the specific entries as required.

Remember that any change to the config file would cause your site to restart, so make sure you take care of all the other housekeeping stuff that this could cause. (Although this would be exactly the same if you where sitting there in the middle of the night copying file around)