[Mono-list] info on configuring mod_mono / mod-mono-server.exe - long...

Chris Turchin chris@turchin.net
Wed, 26 May 2004 23:24:37 +0200


Hi,

it seems like every time I update xsp/mod_mono from cvs, I get to start
over from zero again and reconfigure everything. Okay, perhaps that is
the price of living on the "cutting edge" of software development, I can
live with that. But it occurred to me today, things that used to work no
longer do, and some things that should work still do not seem to, or not
as one might expect. And I have no idea which is which...

The one thing that really bothers / overwhelms me right now is the
enormous variety of options available for configuring mod_mono /
mod-mono-server.exe. Here I would like to just list off a few various
options, I have discovered / stumbled over in the past few weeks which I
wrote down today... 

This is not a rant - though having all configuration data more
centralized and not (mis)configurable in 10 different places
simultaneously might be a request for an enhancement (i know, i know:
bugzilla...) No, this is just a listing of what one can configure for
mod_mono and mod-mono-server.exe, what worked for me (your mileage may
vary), what did not, what 'should' work, where it can be found, and what
its accepted syntax is). So here goes...

BTW, my setup is very simple: just four web apps running on one IP with
one port and no virtual hosts... 

(apache2, mdk9.1, mono, mcs, xsp, mod_mono from cvs)

httpd2.conf /httpd.conf 
#######################

more and more seems to be ending up here. Not a bad thing, keeps things
central at least.

(note: these are mostly very well documented in the man page and can be
found on the http://localhost/server-info page in apache with
descriptions and your current configured settings - just summarizing
here and adding my experiences from today marked with the "***"):

MonoUnixSocket - Named pipe file name. Default: /tmp/mod_mono_server

*** works fine, still have problems with the ownership sometimes, but
this is mostly because i had to revert to starting mod-mono-server.exe
separately, since MonoRunXSP is not working on my machine right now.

MonoRunXSP - It can be False or True. If it is True, asks the module to
start mod-mono-server.exe if it's not already there. Default: False

*** I can't get this one work ATP. It did work but now I get weird
machine.config errors when it starts. Strangely, when I start it by
hand, even as the apache user (assuming /var/www/.wapi exists and is
writable by apache), it works... see below for detailed case-by-case
exceptions based on my attempts today if you are really bored, if you
are at work, or perhaps you are into that sort of thing...

MonoExecutablePath - If MonoRunXSP is True, this is the full path where
mono is located. Default: /usr/bin/mono

MonoPath - If MonoRunXSP is True, this will be the content of MONO_PATH
environment variable. Default: ""
        
MonoServerPath - If MonoRunXSP is True, this is the full path to
mod-mono-server.exe. Default: /usr/bin/mod-mono-server.exe
        
MonoApplications - Comma separated list with virtual directories and
real directories. One ASP.NET application will be created for each pair.
Default: ""  

*** this is apparently depreciated on the command line, but strangely
you can not use "MonoRunXSP True" without it... otherwise you get this
in the err_log and nothing in the browser:

[Wed May 26 21:30:00 2004] [error] Not running mod-mono-server.exe
because no MonoApplications specified.  *** hmm...

MonoWapiDir - See MONO_SHARED_DIR in the mono manual page. Default:
"/tmp" 

*** sucks to be you if you need to start mod-mono-server.exe by hand,
since this is only settable here, otherwise, it seems to default back to
/"var/www/.wapi" - make sure it exists and the apache user has rights to
it... this is in the old FAQ somewhere too...
        
MonoDocumentRootDir - The argument passed in --root argument to
mod-mono-server. Default: /

*** not sure why I need this, since I can just define my applications
with a full path... 

MonoApplicationsConfigFile - The argument passed in --appconfigfile
argument to mod-mono-server. Default: NULL

*** actually not a bad idea, if you knew what the file schema looks
like. see below. :-)
        
MonoApplicationsConfigDir - The argument passed in --appconfigdir
argument to mod-mono-server. Default: NULL

*** see below...

MonoApplicationsConfigFile file
###############################

cool, a configuration file with an undocumented syntax. here is the
syntax for those who would like to know:

<apps>
<web-application>
        <name>{appname}</name>
	<vhost>{virtual host for application}</vhost>
	<vport>{port for the application}</vport>
        <vpath>{virtual directory in apache}</vpath>
        <path>{physical path to aspx files}</path>
</web-application>
</apps>

This I learned by trial and error today: if you do not need a setting
(e.g. vhost or vport), get rid of the entire element! an emtpy element
value e.g. "<vhost></vhost>" is does bad things...


ApplicationConfigDir
####################

Add ApplicationConfigDir and you can have a whole slew of config files
with an undocumented syntax and undocumented naming convention to
configure your webapps with... (they need to be named *.webapp, btw...).
mod-mono-server.exe.config
##########################

Almost forgot all about that one! The mod-mono-server.exe.config file
which also has some settings and configuration options.

I have to admit: i had forgotten about the settings here entirely, and
the fact that blogx was being registered as an application twice (once
here and once in httpd2.conf) was a source of strangeness in my setup i
suspect...)   

Some settings here seem no longer supported - at least i get the message
"--applications option is depreciated" when starting mod-mono-server.exe
as a result of the MonoApplications setting in my config - but this was
at least a good hint that i had better "grep -R" for "blogx" in /etc and
/usr and /usr/local (I don't use it, but just in case) and /data/web and
probably also /var/www (since that is where .wapi/ wants to live now)
and maybe also /home - because _somewhere_ it is being read/referenced
for the configuration and I had no idea where... so i did this, found
that and removed it from there...

For the record, these are the settings one can configure via
mod-mono-server.exe.config:

MonoApplications -- depreciated

MonoServerRootDir -- analog MonoDocumentRootDir from httpd2.conf

MonoServerDefaultIndexFiles -- e.g. index.aspx, if left blank it
defaults to: "index.aspx", "Default.aspx", "default.aspx", "index.html",
"index.htm" 

MonoApplicationsConfigDir -- analog httpd2.conf option
MonoApplicationsConfigFile -- analog httpd2.conf option
UnixSocketFileName -- analog MonoUnixSocket httpd2.conf option

perhaps one could consolidate the naming in these two places?

Command Line Options to mod-mono-server.exe
###########################################

Most if not all settings above can be set via command line. See "APP. 1"
below for the output of "mod-mono-server.exe --help"

More Useful references to mod_mono & mod-mono-server.exe stuff include
######################################################################

http://www.go-mono.com/archive/xsp-0.10.html -- good config info
http://www.go-mono.com/asp-net.html#mod_mono -- general info
http://www.go-mono.com/faq.html#asp -- general info
http://localhost/server-info -- your own module configuration ;-)
http://apacheworld.org/modmono/ -- very old.
http://primates.ximian.com/~gonzalo/mono/blog/index.php -- Gonzalo's
blog

http://cvs.hispalinux.es/cgi-bin/cvsweb/xsp/README?cvsroot=mono
http://cvs.hispalinux.es/cgi-bin/cvsweb/xsp/INSTALL?cvsroot=mono
README,INSTALL, etc online from mono's cvs via cvsweb  if you don't have
them at hand locally...

http://bugzilla.ximian.com -- you might look for your problem here... or
submit it here :-)

http://www.gotmono.com/cgi-bin/yabb/YaBB.pl -- dunno how active this
is...

One More Tip
############

This might seem obvious, but make SURE your browser is not caching
things it should not be. This alone has hung me up searching for
problems on many many occasions (not just with mod_mono). It is no fun
to fiddle with your configuration or an aspx page for two hours only to
realize you had fixed it and your browser was showing you a cached error
message for the last hour and 58 minutes... In firefox, I found this
easiest to do by completely disabling caching with the "TTLO" extension
- the things they left out...

Summary
#######

Now, I have a configuration that is mostly running again. MonoRunXSP is
still whacked but that might be my fault, or some permissions thing
again... But I can start mod-mono-server with a bash script, now so
things are mostly okay.

and all's well that ends well, I guess...

I hope this info helps someone else out there, I know I could have used
it this morning. Parts of it I will submit to bugzilla, if I can get
reproducible test cases and/or clear, coherent critiques and points for
improvement :-)

Regards,

--chris


PS: Below are the command line options to mod-mono-server.exe, a useful
bash script, and the results of various attempts of mine this morning
and the corresponding errors with my workarounds where I could find
them...

APP 1: oUTPUT from mod-mono-server.exe --help
##############################################

mod-mono-server.exe [--root rootdir] [--applications APPS] 
[--filename file][--appconfigdir DIR] [--appconfigfile FILE]

--filename file: the unix socket file name.
	Default value: /tmp/mod_mono_server
	AppSettings key name: UnixSocketFileName

--root rootdir: the server changes to this directory before
	anything else.
	Default value: current directory.
	AppSettings key name: MonoServerRootDir

--appconfigfile FILENAME: adds application definitions from the XML
	configuration file. See sample configuration file that
	comes with the server.
	AppSettings key name: MonoApplicationsConfigFile

--appconfigdir DIR: adds application definitions from all XML files
	found in the specified directory DIR. Files must have
	'.webapp' extension
	AppSettings key name: MonoApplicationsConfigDir

--applications APPS: a comma separated list of virtual directory and
	real directory for all the applications we want to manage
	with this server. The virtual and real dirs. are separated
	by a colon. Optionally you may specify virtual host name
	and a port.

	Samples: /:.
	the virtual / is mapped to the current directory.
		
	/blog:../myblog
	the virtual /blog is mapped to ../myblog
		
	myhost.someprovider.net:/blog:../myblog
	the virtual /blog at myhost.someprovider.net is mapped to ../myblog
		
	/:.,/blog:../myblog
	Two applications like the above ones are handled.

	Default value: /:.
	AppSettings key name: MonoApplications

--nonstop: don't stop the server by pressing enter. Must be used
when the server has no controlling terminal.

--version: displays version information and exits.
--verbose: prints extra messages. Mainly useful for debugging.


Bash Script to start mod-mono-server.exe using --appconfigfile setting
######################################################################

#!/bin/sh
/usr/bin/mono /usr/bin/mod-mono-server.exe --nonstop --root /data/web/
--appconfigfile /data/web/monoconf/apps.conf &
sleep 5
echo "chowning mod_mono_server"
/bin/chown apache:apache /tmp/mod_mono_server


(note: if I don't wait there /tmp/mod_mono_server is not always there
yet for the chown cmd)


Below here are various attempts on my part to get things running today.
Probably not much interest to anyone, except maybe to tell me what I was
doing wrong based on the exceptions :-)

Case One: start mod-mono-server.exe via httpd2.conf with MonoRunXSP:
####################################################################

** doesn't work for me  currently. following appears in err_log:

[Wed May 26 21:30:00 2004] [error] Not running mod-mono-server.exe
because no MonoApplications specified.

*** but I was using:
MonoApplicationsConfigFile "/data/web/monoconf/apps.config"

*** Okay, try again, with an app defined. now I get this in err_log:

** (/usr/bin/mod-mono-server.exe:5712): WARNING **: Invalid sequence in
conversion input
 
Unhandled Exception: System.TypeInitializationException: An exception
was thrown by the type initializer for System.Diagnostics.TraceImpl --->
System.Configuration.ConfigurationException: Error reading
/usr/etc/mono/machine.config() ---> System.NullReferenceException: A
null value was found where an object instance was required.
in (unmanaged) (wrapper managed-to-native)
System.Globalization.CultureInfo:construct_internal_locale_from_current_locale (System.Globalization.CultureInfo)
in <0x00004> (wrapper managed-to-native)
System.Globalization.CultureInfo:construct_internal_locale_from_current_locale (System.Globalization.CultureInfo)
in <0x0000d>
System.Globalization.CultureInfo:ConstructInternalLocaleFromCurrentLocale (System.Globalization.CultureInfo)
in <0x0002c> System.Globalization.CultureInfo:ConstructCurrentCulture ()
in <0x00077> System.Threading.Thread:get_CurrentCulture ()
in <0x00016> System.Globalization.CultureInfo:get_CurrentCulture ()
in <0x00028> System.String:Compare (string,int,string,int,int)
in <0x00077> System.String:StartsWith (string)
in <0x00193> System.Xml.XmlTextReader:ReadAttributes (bool)
in <0x00073> System.Xml.XmlTextReader:ReadXmlDeclaration ()
in <0x00048> System.Xml.XmlTextReader:ReadProcessingInstruction ()
in <0x0006e> System.Xml.XmlTextReader:ReadTag ()
in <0x000cb> System.Xml.XmlTextReader:ReadContent ()
in <0x0014d> System.Xml.XmlTextReader:Read ()
in <0x00087> System.Xml.XmlReader:MoveToContent ()
in <0x0000f> System.Configuration.ConfigurationData:InitRead
(System.Xml.XmlTextReader)
in <0x000b7> System.Configuration.ConfigurationData:Load (string)
--- End of inner exception stack trace ---
 
in <0x00142> System.Configuration.ConfigurationData:Load (string)
in <0x00088> System.Configuration.DefaultConfig:Init ()
in <0x0000f> System.Configuration.DefaultConfig:GetConfig (string)
in <0x00074> System.Configuration.ConfigurationSettings:GetConfig
(string)
in <0x0004b> System.Diagnostics.DiagnosticsConfiguration:get_Settings ()
in <0x0009e> System.Diagnostics.TraceImpl:.cctor ()
--- End of inner exception stack trace ---
 
in (unmanaged) System.Diagnostics.TraceImpl:get_Listeners ()
in <0x0000b> System.Diagnostics.Trace:get_Listeners ()
in <0x00072> Mono.ASPNET.Server:Main (string[])
 
[Wed May 26 21:31:49 2004] [error] Failed connecting and child didn't
exit!

*** No idea what that is all about. Machine.config is readable, so go
figure... Probably a permissions or path issue but I can not figure out
where... so I tried the old method of starting mod-mono-server from my
apache init script - i had always done it this way before, so it was no
big deal (see script above):

Option Two: Start mod-mono-server via apache init script
########################################################

*** again, i get this wierd exception...

** (/usr/bin/mod-mono-server.exe:3575): WARNING **: Invalid sequence in
conversion input
 
Unhandled Exception: System.TypeInitializationException: An exception
was thrown by the type initializer for System.Diagnostics.TraceImpl --->
System.Configuration.ConfigurationException: Error reading
/usr/etc/mono/machine.config() ---> System.NullReferenceException: A
null value was found where an object instance was required.
in (unmanaged) (wrapper managed-to-native)
System.Globalization.CultureInfo:construct_internal_locale_from_current_locale (System.Globalization.CultureInfo)
in <0x00004> (wrapper managed-to-native)
System.Globalization.CultureInfo:construct_internal_locale_from_current_locale (System.Globalization.CultureInfo)
in <0x0000d>
System.Globalization.CultureInfo:ConstructInternalLocaleFromCurrentLocale (System.Globalization.CultureInfo)
in <0x0002c> System.Globalization.CultureInfo:ConstructCurrentCulture ()
in <0x00077> System.Threading.Thread:get_CurrentCulture ()
in <0x00016> System.Globalization.CultureInfo:get_CurrentCulture ()
in <0x00028> System.String:Compare (string,int,string,int,int)
in <0x00077> System.String:StartsWith (string)
in <0x00193> System.Xml.XmlTextReader:ReadAttributes (bool)
in <0x00073> System.Xml.XmlTextReader:ReadXmlDeclaration ()
in <0x00048> System.Xml.XmlTextReader:ReadProcessingInstruction ()
in <0x0006e> System.Xml.XmlTextReader:ReadTag ()
in <0x000cb> System.Xml.XmlTextReader:ReadContent ()
in <0x0014d> System.Xml.XmlTextReader:Read ()
in <0x00087> System.Xml.XmlReader:MoveToContent ()
in <0x0000f> System.Configuration.ConfigurationData:InitRead
(System.Xml.XmlTextReader)
in <0x000b7> System.Configuration.ConfigurationData:Load (string)
--- End of inner exception stack trace ---
 
in <0x00142> System.Configuration.ConfigurationData:Load (string)
in <0x00088> System.Configuration.DefaultConfig:Init ()
in <0x0000f> System.Configuration.DefaultConfig:GetConfig (string)
in <0x00074> System.Configuration.ConfigurationSettings:GetConfig
(string)
in <0x0004b> System.Diagnostics.DiagnosticsConfiguration:get_Settings ()
in <0x0009e> System.Diagnostics.TraceImpl:.cctor ()
--- End of inner exception stack trace ---
 
in (unmanaged) System.Diagnostics.TraceImpl:get_Listeners ()
in <0x0000b> System.Diagnostics.Trace:get_Listeners ()
in <0x00072> Mono.ASPNET.Server:Main (string[])


Option three: start mod-mono-server by hand as apache user
##########################################################

 *** attempt 1)

-sh-2.05b$ /usr/local/bin/mod-mono-server
 
** (/usr/bin/mod-mono-server.exe:2810): CRITICAL **: : shared file
[/var/www/.wapi/shared_data-arcteryx-1-0] open error: No such file or
directory
 
** (/usr/bin/mod-mono-server.exe:2810): CRITICAL **: : shared file
[/var/www/.wapi/shared_data-arcteryx-1-0] open error
 
** (/usr/bin/mod-mono-server.exe:2810): WARNING **: Failed to attach
shared memory! Falling back to non-shared handles
See: http://www.go-mono.com/issues.html#wapi for details
 
** (/usr/bin/mod-mono-server.exe:2814): WARNING **: Invalid sequence in
conversion input
 
Unhandled Exception: System.TypeInitializationException: An exception
was thrown by the type initializer for System.Diagnostics.TraceImpl --->
System.Configuration.ConfigurationException: Error reading
/usr/etc/mono/machine.config() ---> System.NullReferenceException: A
null value was found where an object instance was required.
in (unmanaged) (wrapper managed-to-native)
System.Globalization.CultureInfo:construct_internal_locale_from_current_locale (System.Globalization.CultureInfo)
in <0x00004> (wrapper managed-to-native)
System.Globalization.CultureInfo:construct_internal_locale_from_current_locale (System.Globalization.CultureInfo)
in <0x0000d>
System.Globalization.CultureInfo:ConstructInternalLocaleFromCurrentLocale (System.Globalization.CultureInfo)
in <0x0002c> System.Globalization.CultureInfo:ConstructCurrentCulture ()
in <0x00077> System.Threading.Thread:get_CurrentCulture ()
in <0x00016> System.Globalization.CultureInfo:get_CurrentCulture ()
in <0x00028> System.String:Compare (string,int,string,int,int)
in <0x00077> System.String:StartsWith (string)
in <0x00193> System.Xml.XmlTextReader:ReadAttributes (bool)
in <0x00073> System.Xml.XmlTextReader:ReadXmlDeclaration ()
in <0x00048> System.Xml.XmlTextReader:ReadProcessingInstruction ()
in <0x0006e> System.Xml.XmlTextReader:ReadTag ()
in <0x000cb> System.Xml.XmlTextReader:ReadContent ()
in <0x0014d> System.Xml.XmlTextReader:Read ()
in <0x00087> System.Xml.XmlReader:MoveToContent ()
in <0x0000f> System.Configuration.ConfigurationData:InitRead
(System.Xml.XmlTextReader)
in <0x000b7> System.Configuration.ConfigurationData:Load (string)
--- End of inner exception stack trace ---
 
in <0x00142> System.Configuration.ConfigurationData:Load (string)
in <0x00088> System.Configuration.DefaultConfig:Init ()
in <0x0000f> System.Configuration.DefaultConfig:GetConfig (string)
in <0x00074> System.Configuration.ConfigurationSettings:GetConfig
(string)
in <0x0004b> System.Diagnostics.DiagnosticsConfiguration:get_Settings ()
in <0x0009e> System.Diagnostics.TraceImpl:.cctor ()
--- End of inner exception stack trace ---
 
in (unmanaged) System.Diagnostics.TraceImpl:get_Listeners ()
in <0x0000b> System.Diagnostics.Trace:get_Listeners ()
in <0x00072> Mono.ASPNET.Server:Main (string[])
 
chowning mod_mono_server


*** Okay, so all of a sudden it is looking for /var/www/.wapi instead of
the /tmp/.wapi as defined in httpd2.conf - fine, i will create it. chown
it to apache and then...next attempt:

-sh-2.05b$ /usr/local/bin/mod-mono-server
Adding applications from config file '/data/web/monoconf/apps.conf'
Registering application:
    Host:          any
    Port:          any
    Virtual path:  /blogx
    Physical path: /data/web/blogx
Registering application:
    Host:          any
    Port:          any
    Virtual path:  /gd-gallery
    Physical path: /data/web/gd-gallery
Registering application:
    Host:          any
    Port:          any
    Virtual path:  /Doogle
    Physical path: /data/web/Doogle
Registering application:
    Host:          any
    Port:          any
    Virtual path:  /test
    Physical path: /usr/share/doc/xsp/test
Listening on: /tmp/mod_mono_server
Root directory: /data/web
chowning mod_mono_server

*** beautiful, it works!! As apache, I can start mod-mono-server.exe via
my bash script. So I assume starting it via my init script would work --
but alas, I just same error as above in "Option one"...

[I hope by consolidating this here, people can at least google for
things listed/documented in this mail and find them in a mailing list
archive somewhere]