2

I'm trying to install a Tcl program as a service on my Windows machine using the TclDevKit's TclServiceManager. I'm following the guide here step by step and yet I am experiencing a lot of issues.

If I try to use my raw .tcl file to create the service, I get the following error:

Error 1053: The service did not respond to the start or control request in a timely fashion.

I've followed a solution for this issue here to give the program more time to start up before the Service Control Manager terminates it; to no avail.

Then I decided to try and wrap the program using TclApp and see if that worked. Like the guide says, I used the base-tclsvc-win32-ix86.exe prefix file located in my TclDevKit bin directory. Installing the service that way, and then trying to run it resulted in the following error:

Windows could not start the <service name> service on Local Computer.
Error 1067: The process terminated unexpectedly. 

There wasn't much information at all that I could find googling this error. The only Stackoverflow post on it is this one. So I tried installing the service manually through the command prompt using <TheProgram>.exe <Service Name> -install and tried running it - still gave me the same error.

Then I tried to see if I could get any useful information by running <TheProgram>.exe <Service Name> -debug and interestingly enough I got the following output:

Debugging <Service Name>. 
InitTypes: failed to find the DictUpdateInfo AuxData type

abnormal program termination

Googling InitTypes: failed to find the DictUpdateInfo AuxData type leads me nowhere, however it seems to be something Tcl related.

Finally, if it means anything, the source code for the program I was trying to install as a service is some simple web server code:

proc Serve {chan addr port} {
    fconfigure $chan -translation auto -buffering line 
    set line [gets $chan]
    set path [file join . [string trimleft [lindex $line 1] /]]
    if {$path == "."} {set path ./index.html}

    if {[catch {
        set f1 [open $path]
    } err]} {
        puts $chan "HTTP/1.0 404 Not Found"
    } else {
        puts $chan "HTTP/1.0 200 OK"
        puts $chan "Content-Type: text/html"
        puts $chan ""
        puts $chan [read $f1]
        close $f1
    }

    close $chan
}

if {![info exists reload]} {
    set sk [socket -server Serve 3000]
    puts "Server listening on port 3000"
    vwait forever
} else {
    unset reload
}

To check and see if the source code was the problem, I tried another, simpler example that simply created a file in a particular directory:

set filePath "C:/some/path/here";
set fileName "Test.txt";

set file [open [file join $filePath $fileName] w];
puts $file "Hello, World";

close $file;

Both programs work if you simply source them from tclsh86.exe, but give the above errors if you try and run them as services unwrapped and wrapped respectively.

Any ideas?

Community
  • 1
  • 1
Vee
  • 729
  • 10
  • 27
  • Might be a bad idea to use `puts "Server listening on port 3000` inside a service, as you do not have a working stdout by default. That would explain the 'terminates unexpectedly'. – schlenk Mar 22 '16 at 23:34
  • Thanks! I'll try removing it and see if it works! Goodness, if that's the problem I will be so relieved and annoyed haha. – Vee Mar 30 '16 at 14:23

0 Answers0