Version 3 of Tclhttpd as a Windows Service

Updated 2003-11-21 07:09:18

I'm looking at the possibility of turning Tclhttpd into a Windows (NT, 2000, etc.) service. Currently, I'm using ActiveState's Tcl Dev Kit to facilitate this. Does anyone have experiences or advice to relate on this topic?

- WJR


JH This is possible starting with Tcl Dev Kit. You have to watch out for the various special handling that Windows services require. If you have timeout startup issues, you need to look for bare

        vwait forever

which is typical in server scripts to start the event loop, but must not exist for NT Tcl services. This is correct:

    if {![info exists tcl_service] && ![info exists tk_version]} {
        vwait forever
    }

WJR For Tclhttpd 3.4.2, this is line 328 in tclhttpd3.4.2/bin/httpd.tcl. After I made this change, the service worked like a charm. In my case, I'm using version 2.6.1 of the Tcl Dev Kit, using the httpd.tcl script as the service (I'm not using a Starkit). Some things to look into:

  • In bin/tclhttpd.rc, my logs should be written to ../logs, but for some reason they're being put into C:\WINDOWS\logs
  • I had to put the Tcllib dir on the same level as the Tclhttpd dir.
  • CGI scripts don't seem to work. Windows event log errors are generated.

For those wanting to create an actual starpack (single-file executable) out of tclhttpd on Windows, you will need Tcl Dev Kit 3.0, which includes a base kit designed for use as an NT service.