Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hosting Mercurial with IIS 6

I'm trying to set up Mercurial repositories to be hosted by IIS under Windows Server 2003. Following this post I installed Python 2.5.4.4 and Mercurial 1.3, set up virtual dir, extracted library.zip and created hgwebdir.config.

However, when I trying to open the http://hostname/hg/hgwebdir.cgi I got an error “The specified CGI application misbehaved by not returning a complete set of HTTP headers.” I did all by best:

  1. Checked IIS mappings to both .py and .cgi extensions. I even tried to use FastCGI with no success.
  2. Created “Hello World” in the same dir and checked that it works fine.
  3. Checked read/exec permissions to Python, IIS and repos directories for IUSR, IWAM and NETWORK SERVICE.
  4. Tried to apply two different patches from Mercurial mailing list. Since they both are old I haven't success with it.
  5. INstalled Sysinternals' procmon and checked for filesystem errors during request. I found nothing except lots of Buffer Overflow results in Python process while it loads it's libraries.
  6. Tried to add 'Content-type: text/html' to the script.

One more thing is when I'm requesting inexistent script file (e.g /hg/inexist.cgi) I have the same error. Nothing helped!

like image 393
Artem Koshelev Avatar asked Jul 27 '09 23:07

Artem Koshelev


2 Answers

Some more things that I needed to fix:

  • Where the various HOWTOs say to use c:\whatever\Python26\python.exe -u "%s" "%s" instead use c:\whatever\Python26\python.exe -u -O -B "%s" "%s" -O causes it to also look for .pyo files (not just .py or .pyc, which at least in my version weren't present). -B causes it to not attempt to compile .py files that it finds into .pyo files (which fails due to lacking write permissions)
  • I'd installed Python 2.7. Mercurial 1.6.2's .pyo files were compiled with Python 2.6. This resulted in a magic number error. Uninstalling 2.7 and installing 2.6.5 fixed this. (If you're reading this at some point in the future, this point may no longer be relevant - check the name of the DLL in Mercurial's directory, or TortoiseHg's directory, depending on where you took library.zip from)
  • hgwebdir.cgi is now just hgweb.cgi - webdir was integrated into it
like image 151
Jon Bright Avatar answered Sep 27 '22 19:09

Jon Bright


Finally I got that "no headers" error returned on any python script error, so I checked script with console interpreter and fixed errors in my config file. And of course I should ask this question at ServerFault instead of StackOverflow - the lack of sleep did the job :)

like image 40
Artem Koshelev Avatar answered Sep 27 '22 19:09

Artem Koshelev