This is a really easy way to create really reliable and flexible systems. Highly recommend you go this route, rather than trying to recreate a webserver or database.
So I was probably too vague in my original description. This is supposed to be a server-to-server application. Similar to how New Relic's integration monitors your server and reports home to their servers. So something like this:
The "adapter" will sit on "Client App" and interface with their database, reporting back to "Web App". I need something that is compact and relatively portable, so that it can be installed on client servers with minimal hassle. It will be provided limited access to various attributes of the client's database.
Edit: Damnit. How'd you get your ascii formatting to stick? Edit2:Got it!
Well, I'd still treat it like any other "Client App". It does make more sense for it to be a long-lived daemon though.
If it's the kind of thing where you can run it once in a while:
$ bin/myagent --daemon
.. while 1
.... exec bin/myagent --report
.... sleep 300
$ bin/myagent --report
.. hit the Database
.. send to Web App
.. exit
Or maybe you want to be able to send requests to the daemon from outside? The issue there would be firewall rules generally.
Personally, I highly recommend you avoid creating a smart daemon and recommend the approach above if it will work at all. Embedding a web server (or similar) tends to create all kinds of issues, including performance, firewll, memory issues, logging, etc.
I originally wanted bi-directional communication, since it would simplify command processing. But you're right, that's just asking for all kinds of problems.
It'll be easier to have the client poll the server to find out updates or new commands.