wolfwings: (Default)
wolfwings ([personal profile] wolfwings) wrote2008-05-05 06:49 pm

Making a Windows Service isn't that hard...

...managed to port that source code from earlier to a Windows Service that behaves correctly, though it only supports Start/Stop, I couldn't think of a sane state to handle Pause/Resume since there's no solid answer to 'should a web server finish existing requests, close existing requests, or just 'hang' existing requests when paused?' that I could find.

Still, pleased with myself, now to work on a DNS filter that'll automatically integrate itself into the existing network stack, and then integrate that with the main program so it'll be a single executable/service to deal with. Then comes the hard part: Adding configuration screens to adding new domain-names to block like this.

I think there might actually be a market for this sort of thing, if I can manage to make it not break corporate Windows networking's wierd DNS requirements and what-not.

(Anonymous) 2008-05-06 12:39 am (UTC)(link)
It sounds like you've been pretty busy! :-)

[identity profile] lionman.livejournal.com 2008-05-06 12:40 am (UTC)(link)
Lemme try this again:

Looks like you've been busy! :-)

Yup!

(Anonymous) 2008-05-06 01:41 am (UTC)(link)
Productive-busy, but definately busy. :-)

Re: Yup!

[identity profile] lionman.livejournal.com 2008-05-06 03:07 am (UTC)(link)
Productive busy is the best sort of busy, isn't it? :-)

Re: Yup!

[identity profile] lionman.livejournal.com 2008-05-06 03:27 am (UTC)(link)
How's work and stuff going?

Re: Yup!

[identity profile] wolfwings.livejournal.com 2008-05-06 03:51 am (UTC)(link)
A little busy tonight, but in a good way. Again, productive-busy. =^.^=

[identity profile] sebkha.livejournal.com 2008-05-06 03:26 am (UTC)(link)
I think a paused web server should finish existing requests and reply 503 to new ones.

If it was a full-fledged web server, that makes sense.

[identity profile] wolfwings.livejournal.com 2008-05-06 03:40 am (UTC)(link)
In this case, it actively ignores the actual request, and sends back a single reply regardless of URL asked for, a 1x1-pixel transparent GIF. Supporting pause/resume is optional, so I decided against doing so since it would have noticably enlarged a very tiny, very compact service.

In this case, the compiled executable is only 8kB in size actually, despite obeying ALL Windows semantics and steps to do WinSock calls, handle Windows errors cleanly if abruptly, and provide minimal logging to the Event Log when it starts up and shuts down.

[identity profile] aerowolf.livejournal.com 2008-05-06 10:53 am (UTC)(link)
The best definition of 'pause' in my mind is:

Temporarily stop accepting new requests, returning "temporary condition, please try again in a few moments" results if possible
Finish servicing existing requests

The general idea is "if you need to stop/restart the database, it makes sense to perform an orderly reduction of load without causing large amounts of errors and thus calls to the help desk."

If the administrator wants the existing connections to be closed forcefully, the administrator will stop the service.

As you've noticed, pause/resume semantics are optional.