Tclhttpd Winservice

From time to time, I'm working on a starpack based on tclhttpd v 3.5.1 which can be run as a Windows Service through the help of Winserv. Additional descriptions are at the bottom and some more probably will be added later.

However, the starpack can be run as a normal program too, not only as a service.

You can download it here: http://home.arcor.de/hoffenbar/prog/tclhttpd.zip (64bit Testversion: [L1 ])


https://image.jimcdn.com/app/cms/image/transf/none/path/s1b9371b41c82e69b/image/i21d1ba78c9049fbc/version/1490297270/image.jpg


Example cmdline help: (note that it may differ from release to release and from environment to environment as some defaults like paths are constructed dynamically)

 tclhttpd.exe 0.85, based on tclhttpd 3.5.1 and Tcl 8.4.19, modified 24.11.2008 22:41:52, MHo
 usage: tclhttpd.exe {[options]|scriptfile}
 -virtual value       Virtual host config list <>
 -config value        Configuration file <D:/Home/Arbeit1/pgm/tcl/usr/Src/httpd351pack4/tclhttpd.exe/bin/tclhttpd.rc>
 -main value          Per-Thread Tcl script <D:/Home/Arbeit1/pgm/tcl/usr/Src/httpd351pack4/tclhttpd.exe/bin/httpdthread.tcl>
 -docRoot value       Root directory for documents <D:/Home/Arbeit1/pgm/tcl/usr/Src/httpd351pack4/tclhttpd.exe/bin/../htdocs>
 -port value          Port number server is to listen on <8015>
 -host value          Server name, should be fully qualified <matthias>
 -ipaddr value        Interface server should bind to <>
 -https_port value    SSL Port number <8016>
 -https_host value    SSL Server name, should be fully qualified <matthias>
 -https_ipaddr value  Interface SSL server should bind to <>
 -webmaster value     E-mail address for errors <webmaster@matthias>
 -uid value           User Id that server runs under <50>
 -gid value           Group Id for caching templates <50>
 -secs value          Seconds per "minute" for time-based histograms <60>
 -threads value       Number of worker threads (zero for non-threaded) <10>
 -library value       Dir list where custom packages and auto loads are <D:/Home/Arbeit1/pgm/tcl/usr/Src/httpd351pack4/tclhttpd.exe/bin/../custom>
 -debug value         If true, start interactive command loop <0>
 -compat value        Version compatibility to maintain <3.3>
 -gui value           Flag for launching the user interface <1>
 -mail value          Mail Servers for sending email from tclhttpd <>
 -LogFile value       Location and name prefix for logfiles <s:/tmp/log>
 -tclcgi value        Runtime to execute tcl-CGIs <C:/Programme/Tcl/bin/tclsh.EXE>
 -AuthDefaultFile value Location for internal authfile <s:/tmp/tclhttpd.default>
 -unpacktools         Extract included tools and docs
 -morehelp            Show a few background infos
 -help                Print this message
 -?                   Print this message

Output of -morehelp

 This Webserver is based on tclhttpd v3.5.1 and a tcl runtime (either a tclkit
 or a basekit ActiveTcl, e.g.).

 This starpack is designed to run as a Windows service through Winserv. It can
 be started interactively, too.

 The VFS-internal htdocs and libs are stripped down somewhat to reduce exe
 size. They are always available unter /adminroot. The CGI demos will not run
 out of the VFS! Code from internal custom dir is loaded first. The 'real'
 custom dir is expected to be outside the VFS, because it's subject to
 changes all the time. Also, it's likely that you will have your own
 tclhttpd.rc-Configuration-file.

 On windows, the auto_path is automatically extended to the lib folder of an
 existing Tcl installation (auto_execok tclsh/../lib). If there is such an
 installation, it also runs Tcl-CGIs. If not, tclkitsh is searched. The last
 fallback is that this program also runs the CGIs.

 An example for installing this starpack as a service:

 winserv install httpd1 -ipcmethod stdio -start demand -description "tclhttpd1"
  -user .\xyz -password abc d:/progs/tclhttpd.exe -config d:/my/httpd.rc
  -library d:/my/custom
 winserv start httpd1

 tclhttpd.exe is under development, so the .exe will change frequently.

 things that could be done or should be noticed:
   - incorporate changes/fixes from later (3.5.2/CVS)-versions
   - replace the cmdline/config-parsing with Spar and readprof (see wiki)
   - adapt new homepage (see https://wiki.tcl-lang.org/11420 and
      http://www.frbc-va.org/mockup/); a dummy is available at /home2.html
   - create config/tclhttpd.rc equivalents for the newly added cmdline switches
   - add support for more cgi interpreters (php, ...) (no #!-magic on MS Win)
   - reimplement PAUSE and CONTINUE functions in a better way, and implement
      service control e.g. to query several states of the server
   - eventually add separate event logging for Windows eventlog, and/or
     reorganize the whole stdout/stderr/console output stuff
   - (Re-)integration of wikit (whipit), see https://wiki.tcl-lang.org/11121
   - look further at https:-Support

 ! * use the right account for the service; watch the environment, especially
 !   the PATH-var (additional env-vars could be added through custom code)
 ! * avoid using backslashes in command line arguments; they are not yet
 !   automatically translated

 M.Hoffmann, 2006-2008

(As said, the program will change from time to time and so will this help text.)


To access the build in docs and admin-tools, simply start tclhttpd without any parameters and navigate your browser to localhost:8015. These are always available via url /adminroot even if you have configured your own docRoot (some links may still not work yet).

To implement tclhttpd as a service, you need Winserv, which is available inside tclhttpd.exe an can be extracted via -unpacktools command line switch.


RLH 2006-04-10: Why version 3.4.2 when 3.5.1 is the latest release? MHo I tried 3.5.1 several times and never succeeded in getting it servicing our existing intranet site, driven by 3.4.2/3.4.3 without modifications. It seems to me that there are some changes that are not upward compatible (probably in doc.tcl). I'm working on this. 2006/07/18: v3.5.1 is now the base of my modifications. Remember: Specifying URLs without the .tml-extension only works anymore with documents specifying [Doc_Dynamic]...


History

  • 25.04.2006: Switched to one of the latest dqkit-runtimes (threaded).
  • 12.05.2006: Done auth for /admref (not reflected in -morehelp yet). UserID and password are fixed for now to webadm, /#&goony+
  • 23.05.2006: Switched to tclhttpd v3.5.1; changes not yet reflected here or elsewhere (testing and config in progress). My personal homepage space is exhausted, so I'm currently not able to post any new releases...
  • 18.07.2006: Many many changes to make v3.5.1 work; too many to note them here. Command line changed, help changed accordingly. Basic functionality should be ok now.
  • 28.07.2006: Switched to winserv's -ipcmethod stdio. Several internal changes to work around difficulties with service-mode etc.
  • 25.08.2007: New Version 0.5 with some enhancements (many module and documentation updates and some additions, e.g. tcllib 1.9). Runtime is base-tclsh from Activestate, version 8.4.15. As usual, the changes are not documented in detail here. If interested, post a note here.-
  • 18.10.2007: v0.6 with Tclruntime 8.4.16, some internal docs updated, some unusable code ZIPed, integrated gzip updated, .EXE-size reduced, modules from newest tcllib.
  • 23.10.2007: modified lib/tclhttpd/fallback.tcl to avoid generating double slashes // at the beginning of an URL (see [L2 ])

History for v0.7 and above:

25.10.2007-02.11.2007, v0.7:

  • if no interpreter for CGIs is found, CGIs are interpreted by tclhttpd.exe itself!
  • removed some *Nix-specifica, because this is primilary designed to be a windows program
  • removed Ajuba- and ScripticsLogo*.GIF from htdocs/images (not referenced anywhere)
  • textutil/*.tex replaced by 0 Byte-dummies (not referenced anywhere)
  • htdocs/manual/htdig.html and references removed (very old and for *Nix only)
  • bin/backup_org.zip/util/* (crypt etc.) removed (only *Nix)
  • htdocs/snmp* removed (only makes sense with Scotty and with *Nix, I guess)
  • removed obsolete backup-ZIPs from VFS
  • gzip.exe + docs removed; Logfiles are now ZIPped internally (external gzip.exe only as a fallback) I hope this internal zipping does not the block the whole server for too long periods...
  • Reduced size by ~200k

25.01.2008, v0.8, MHo (sorry: not tested very well yet):

  • bugfix in log.tcl, ZIPped logs where not deleted...
  • runtime now is base-tcl-thread-win32-ix86.exe v8.4.17 from ActiveTcl
  • updated doctools, mime and fileutil and associated manpages
  • removed unneccessary module env from cgi-bin/cgi-bin.zip (*NIX ELF binary makes no sense with Windows) and multiple occurence of some README
  • reduced overall EXE size by approx. 4k

27.01.2008, v0.81, MHo:

  • fixed bug in command line / .rc-file processing (LogFile in .rc has been ignored, internal default always took precedence. Had to specifiy command line switch to overwrite.)

09.07.2008, v0.82, MHo: Time for some changes ;-)

  • Runtime is base-tcl-thread-win32-ix86.exe from ActiveTcl v8.4.19
  • the used parts of textutil updated to v0.71
  • md5crypt updated to v1.10
  • doctools updated to v1.3.2
  • removed unused stuff from zipper/pkgIndex.tcl
  • fixed htdocs/notfound: 'home'-link returns to / instead to non-existing cgi-bin/index
  • fixed bug in newauth (updated to v0.4) and updated documentation for newauth (still "eine Baustelle")

23.09.2008, v0.83, MHo:

  • Runtime base-tcl-thread-win32-ix86.exe 8.4.19.1
  • Refreshes from tcllib 1.10:
  • fileutil
  • md5, md5crypt
  • mime
  • ncgi
  • cmdline
  • base64
  • doctools

20.11.2008, v0.84, MHo:

  • Fixed an awfull bug which prevents from loading if a certain regkey was missing (regkey only present if ActiveTcl installed)...
  • Removed some critcl code from rc4c, md5c, md5cryptc (makes no sense here)
  • Experimental 64bit-Version (link removed - see link at the top), which probably won't run as a service, because winserv.exe and nologoff.dll are still 32bit. Not tested yet.
  • Experimental Version with Tcl 8.5.5 runtime (link removed - normal distro now based on 8.5.6). Should work but don't... There's a difference I don't understand yet in httpdthread.tcl preventing VFS-internal custom code from loading... (see below)
  • Sometimes, under some circumstances with have to do with the internal httproot, pageloads never come to an end.

26.11.2008, v0.85, MHo:

  • Minor changes.

28.11.2008, v0.86, MHo:

29.11.2008, v0.87, MHo:

30.11.2008, v0.88, MHo:

  • Now using iocpsock (error that some GIFs don't load from internal VFS (/adminroot/images)still present!; iocpsock not tested very well yet)
  • minor corrections

01.12.2008, v0.89, MHo:

  • fixed: program won't run out of folder with blanks in it's name (various symptoms, e.g. mime.types don't get loaded etc.)
  • minor corrections

04.02.2009, v0.90, MHo:

  • Drop the use of iocpsock because of diffuse intermittently errors (http downloads of large files stop at different stages, leaving the file (and socket) handle open - 64 bit Windows Server). Now, everythings is a little bit slower...
  • Fixes in status.tcl (body and html-closing tags where missing). Still page load of graphical state never comes to an end for reasons I cannot track down.
  • Some other page loads don't come to an end, too, if the webserver and browser run on localhost (or other environmental settings...) - there must be a fundamental bug somewhere!
  • Minor change in status.tcl for tcl 8.5 (removed integer from lsort -integer [Thread_List] somewhere).
  • Runtime now is tclkitsh 8.5.6 (not completely tested yet). Error [L3 ] seems to be solved.
  • Incorporated some more minor changes from 3.5.2

  • In the next releases (if there will be some), I plan to remove the manual stuff since nobody looks into it or it's partly outdated.
  • What has to be examinated is the behaviour of the tandem 32bit winserv service wrapper + 64bit httpd - will this work???

Glob problem w/tclvfs and Tcl 8.5.*???

Now reported at: http://sourceforge.net/tracker/index.php?func=detail&aid=2378350&group_id=32692&atid=406308

 httpd % glob $::starkit::topdir/bin/../custom/*
 no files matched glob pattern "D:/Home/Hoffmann/pgm/tcl/usr/Src/httpd351pack4/tc
 lhttpd8.5.5_32.exe/bin/../custom/*"

A workaround would be:

  glob -directory $::starkit::topdir/bin/../custom/ *