A Blog Less Ordinary

The blog of Dave Ingram

mod_sqltemplate: A distraction from work

I’ve begun the long and (hopefully) interesting task of working on mod_sqltemplate. �I have not yet found a tutorial or guide to working with APR’s DBD API (the database abstraction layer for the Apache Portable Runtime), so I’ll write one and publish it here as I go along…

14 Responses to mod_sqltemplate: A distraction from work

David Durant says: September 10, 2008 at 22:05

Wouldn’t it make more sense to put the info on a wiki so that (1) other people can contribute in the future and (2) people can subscribe to an RSS feed for changes so you don’t need to post updated.

David Durant says: September 10, 2008 at 22:07

Grrrrr – if you get the catchpa wrong on this page it ditches your comment which is very annoying. Why even have a catchpa anyway?

Anyway – why not put this on a wiki so (1) other people can contribute to it in future and (2) people can subscribe to an RSS feed from it so you don’t need to post updates.

Dave says: September 10, 2008 at 22:39

You’d be surprised at how much spam this blog attracts, and how effective reCAPTCHA has been at blocking the majority of it. And this isn’t even a high-traffic blog, by any means.

It shouldn’t ditch your comment though – that’s bad design on the plugin author’s part or misconfiguration on my part.

If anyone is interested, this is on a wiki at http://wiki.dmi.me.uk/ but you do have to register for an account. Once I have time to restrict certain parts of the wiki, then I’ll make it open-registration.

babul says: November 1, 2008 at 02:28

Just thought I’d write to say congrats on the apache module. First steps are always the hardest 🙂

G. Schuster says: November 16, 2009 at 11:35

One year since the last comment…is this project still active?
I’m really interessted in the module as there’s no real alternative for storing the vhosts in a database.
What I haven’t found in the docs so far – does it require me to restart Apache after each DB change?

Is there any chance to get the mod to a stable version soon?
I’d be happy to aid the development with comments and ideas if you’re interessted.
You can find my contact details on my website @ www [dot] actra [dot] de

Dave says: November 16, 2009 at 12:35

Wow, has it really been a year? The project is undergoing some work (see http://www.dmi.me.uk/code/apache/mod_sqltemplate/) to fix the database access under various conditions, which I hope to have working shortly.

It does require forcing Apache to reload its configuration after every DB change (i.e. a graceful restart rather than a full restart) as there is no other way of forcing the affected sections to be re-processed properly.

Once I’ve got the database subsystem sorted, I’ll be releasing 0.1 stable.

G. Schuster says: November 16, 2009 at 19:49

I’ve seen there’s been an update 04.11.2009 but dates don’t always indicate “real” activity 😉

Manual reloads are exactly the thing I hoped to abandon with an SQL based vhost-config.
Just thinking out loud…but shouldn’t it be possible to internally poll the database for a “changed” flag and then automatically do a reload?
I’ll try to get my hands dirty on that, but don’t expect any results as I’ve never really worked with C.

Dave says: November 16, 2009 at 21:31

I�ve seen there�s been an update 04.11.2009 but dates don�t always indicate �real� activity

Heh, very true. I’ve been working on it a little this evening, but work is going to be extremely busy this week.

Manual reloads are exactly the thing I hoped to abandon with an SQL based vhost-config.
Just thinking out loud�but shouldn�t it be possible to internally poll the database for a �changed� flag and then automatically do a reload?

I’ve had that suggested, and the best way forward would seem to be a pair of configuration options. The first would be an interval to check for updates, and the second would specify a table (or tables) that should have their update times polled. If the update time is greater than the last poll time, internally force a config reload.

G. Schuster says: November 16, 2009 at 22:25

I hope I didn’t offend you with my statement about activity – if so I’m sorry and apologize.

The config option sounds like a good idea.
Without internal reloads storing configs in a DB wouldn’t make real sense to me.

As the topic urged me on finding more details I’ve come up with mod_perl.
Especially the Apache2::PerlSection module is interessting as it enables one to define whole config sections in pure perl.
The examples also list dynamically configured vhosts – so maybe you can get some inspirations from it.
See the docs at cpan: Apache2::PerlSections
I’m going to play with it the next days as my Perl skills are far better than my C skills…maybe that’s already the soultion to my current problem so I don’t have to put you under stress 🙂

Dave says: November 16, 2009 at 22:52

I hope I didn�t offend you with my statement about activity � if so I�m sorry and apologize.

Not at all! I know progress hasn’t exactly been lightning-fast, but there are a lot of demands on my time.

The config option sounds like a good idea.
Without internal reloads storing configs in a DB wouldn�t make real sense to me.

My main reason for storing in a database was to reduce repetition. I figured that the configuration would be changing relatively infrequently, and that I would always know when the changes happened, I wouldn’t mind reloading the config myself.

If you find that mod_perl and the config sections meet your needs, then great! I’m not convinced by it myself, and I don’t always want mod_perl in servers that I configure. Having said that, everyone’s needs are different…

G. Schuster says: November 17, 2009 at 00:03

Well, my “need” is to hav – at best – an Apache that doesn’t need a reload at all.
But as my tests within the last hours showed this seems to remain a dream.
I think I’m going the easiest way for now – generate the config files from a DB with a small Perl daemon polling for updated files and then reloading the config.
To cut the long story short: I’m still interessted in mod_sqltemplate so keep up the work 🙂

Dave says: November 17, 2009 at 00:12

Apache isn’t coded in a way to allow that. The only way to reprocess the config is to get it to reload it. There’s also the complication in the case of mod_sqltemplate that database configuration could be *anywhere*, not just in a virtual host. You could even use it to control inclusion of modules, or other global directives if you really wanted. Virtual hosts are the most common use case for this sort of thing, but all sorts of other applications are possible. There really is no other sane way to do it, I’m afraid 🙂

In short, the only way you can have Apache that doesn’t need a reload is to have one for which the configuration never changes 😉

G. Schuster says: November 21, 2009 at 20:34

Just to let you know – I digged into this a little further.
As there’s no “real” dynamic configuration I at least managed to automate the Apache reloads.
My test setup now uses mod_perl for “dynamic” configuration and “incrontab” to watch the filesystem for a touched file.
Everytime I change my DB I only have to touch() the watched file and – magic – Apache reloads.
It’s surely not perfect but until mod_sqltemplate has the perfect solution it’s suitable 🙂

Ba says: March 10, 2011 at 14:24

hi Dave your mod_sqltemplate is fantastic il love it so much no i’am trying to use it in my project but i have a probleme hi does’nt work in my computer i dont known why:
i have ubuntu system and installed lamp-server meaning apache2 php and mysql. help me please.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

 

GitHub Google+ Twitter