[Mono-list] How to run only one instance of mod-mono-server?

Andreas Heyer Andreas.Heyer at uni-jena.de
Mon Jan 23 08:11:31 EST 2006


Hello,

I will use mono-1.1.13/mod_mono with Apache 2.0. The samples from the
mod_mono web page work as described, although I never get auto applications
(that means, every .aspx page is handled by mod_mono) to work. But when
trying the xsp test pages I discovered that for every page a new child
process is forked. So after a couple of pages I got many mono processes, but
I wasn't so patient to wait for their disappearing. I don't know when they
will die.

So ok, I tried one single instance of mod-mono-server. Some of you asked how
to made xsp daemonized, so here's my config for mod-mono-server (SuSE 9.3):

----------------------------------------------------------------------------
----------------
/ect/init.d/mono-server (modified /etc/init.d/skeleton)

[...]
# /etc/init.d/mono-server
#   and its symbolic link
# /(usr/)sbin/rcmono-server
[...]
### BEGIN INIT INFO
# Provides:          Mono ASP.NET
# Required-Start:    $syslog
# Should-Start:
# Required-Stop:     $syslog
# Should-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: mod-mono-server provides ASP.NET for Apache
# Description:       mod-mono-server from Mono running as master deamon
#	for ASP.NET applications hosted on Apache
### END INIT INFO
[...]
# Check for missing binaries (stale symlinks should not happen) # Note:
Special treatment of stop for LSB conformance
FOO_BIN=/opt/mono/bin/mod-mono-server
[...]
FOO_CONFIG=/etc/sysconfig/mono-server
[...]
# Read config	
. $FOO_CONFIG
[...]
case "$1" in
    start)
	echo -n "Starting mono-server "
	## Start daemon with startproc(8). If this fails
	## the return value is set appropriately by startproc.
	startproc -u wwwrun $FOO_BIN$SERVER_VERSION $START_ARGUMENTS &
	
	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down mono-server "
	## Stop daemon with killproc(8) and if this fails
	## killproc sets the return value according to LSB.

	$FOO_BIN$SERVER_VERSION $STOP_ARGUMENTS

	# Remember status and be verbose
	rc_status -v
[rest omitted]

----------------------------------------------------------------------------
------------

/etc/sysconfig/mono-server

# Set to 2 to use ASP.NET 2.0
SERVER_VERSION=""

# Set to yes to use tcp
use_tcp="no"

address="127.0.0.1"
port="9000"

# Listen on socket socket="/var/lib/mono-server/mono-server-default"

# Run as (default: same as apache worker)
user="wwwrun"

if [ "$SERVER_VERSION" != "2" ]; then
	SERVER_VERSION="" ;
fi;

if [ "$use_tcp" = "yes" ]; then
	listen="--address $address --port $port" ;
else
	listen="--filename $socket";
fi;

START_ARGUMENTS="$listen --master --nonstop --root /srv/www/htdocs &>
/dev/null" STOP_ARGUMENTS="$listen --terminate"

----------------------------------------------------------------------------
-------------------------

With these 2 files mod-mono-server is startet in runlevel 3&5 after
"chkconfig --add mono-server". It will listen as master on a socket file or
a tcp port (according to my settings in /etc/sysconfig/mono-server). That
will work fine, I can see the socket file or the listening port. Also
stopping the service is ok, but I never tried the other commands (reload
etc.) for that rc script.

Now move on to Apache config. Here's a part of a virtual host config file:

----------------------------------------------------------------------------
------------------------
Include /etc/apache2/conf.d/mod_mono.conf
    
Alias /test "/opt/mono-1.1.13/lib/xsp/test"
    
MonoAutoApplication disabled

MonoUnixSocket default /var/lib/mono-server/mono-server-default #use as
needed for demonized mod-mono-server
#MonoListenAddress default 127.0.0.1
#MonoListenPort default 9000

MonoRunXSP default false
MonoApplications default
"myhost.domain.tld:/test:/opt/mono-1.1.13/lib/xsp/test"
    
<Location /test >
	MonoSetServerAlias default
	SetHandler mono
	Order Allow,deny
	Allow from all
</Location>	

----------------------------------------------------------------------------
-------------------------

I recompiled mod_mono from source with debug output enabled. In my Apache
logs I can see that mod_mono tries several times to connect
/tmp/mod_mono_server_default during start of Apache. I thought with
"MonoAutoAplications disabled" or "MonoRunXSP false" mod_mono only uses the
server I gave it with MonoUnixSocket or MonoListenAddress/Port and use this
demonized "master" to create all applications??? When I ask for
/test/index.aspx in my browser I only get the source code (I disabled the
MIME settings in mod_mono.conf)! But there's no error, just an ordinary 200
in the access logs. Mod_mono itself logged this:

----------------------------------------------------------------------------
-------------------------------

During Apache startup:

[Fri Jan 13 12:34:22 2006] [warn] Socket file name
/tmp/mod_mono_server_otherhost.domain.tld
[Fri Jan 13 12:34:22 2006] [warn] errno in try_connect 2 No such file or
directory
[Fri Jan 13 12:34:22 2006] [warn] try_connect: -1 
[Fri Jan 13 12:34:22 2006] [warn] forking otherhost.domain.tld
[Fri Jan 13 12:34:22 2006] [warn] Applications: (null)
[Fri Jan 13 12:34:22 2006] [warn] Config file: (null)
[Fri Jan 13 12:34:22 2006] [warn] Config dir.: (null)
[Fri Jan 13 12:34:22 2006] [error] Not running mod-mono-server.exe because
no MonoApplications, MonoApplicationsConfigFile or MonoApplicationConfigDir
specified.
[... This repeats several times, but I can't see a section where the app
from above (xsp test files) is created?

Now the logging of a request for index.aspx:
...]
[Fri Jan 13 12:35:17 2006] [warn] handler: mono
[Fri Jan 13 12:35:17 2006] [warn] config = 136094680
[Fri Jan 13 12:35:17 2006] [warn] dir_config = 136098016
[Fri Jan 13 12:35:17 2006] [warn] idx = 1
[Fri Jan 13 12:35:17 2006] [warn] Socket file name
/var/lib/mono-server/mono-server-default
[Fri Jan 13 12:35:17 2006] [warn] try_connect: 0
[Fri Jan 13 12:35:17 2006] [warn] After setup_socket
[Fri Jan 13 12:35:17 2006] [warn] Sending init data
[Fri Jan 13 12:35:17 2006] [warn] Send init1
[Fri Jan 13 12:35:17 2006] [warn] Host: myhost.domain.tld
[Fri Jan 13 12:35:17 2006] [warn] User-Agent: Mozilla/5.0 (Windows; U;
Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5 [Fri Jan 13
12:35:17 2006] [warn] Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5
[Fri Jan 13 12:35:17 2006] [warn] Accept-Language:
de-de,de;q=0.8,en;q=0.5,en-us;q=0.3
[Fri Jan 13 12:35:17 2006] [warn] Accept-Encoding: gzip,deflate
[Fri Jan 13 12:35:17 2006] [warn] Accept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.7
[Fri Jan 13 12:35:17 2006] [warn] Keep-Alive: 300
[Fri Jan 13 12:35:17 2006] [warn] Connection: keep-alive
[Fri Jan 13 12:35:17 2006] [warn] If-Modified-Since: Fri, 06 Jan 2006
23:48:24 GMT
[Fri Jan 13 12:35:17 2006] [warn] If-None-Match: "144a19f-a08-48ee0200"
[Fri Jan 13 12:35:17 2006] [warn] Cache-Control: max-age=0
[Fri Jan 13 12:35:17 2006] [warn] Loop
[Fri Jan 13 12:35:17 2006] [warn] Command received: DECLINE_REQUEST
[Fri Jan 13 12:35:17 2006] [warn] Done. Status: -1
[...] Now there comes the same log entries from Apache start above?

As you can see mod-mono-server returns a DECLINE_REQUEST to mod_mono. As I
understand the server code, it gaves this reply when there is no application
defined. But I used MonoApplications!?

So I ask you how to use only one running instance of mod-mono-server as
master and create a valid app there? If I use "MonoRunXSP true" I get valid
compiled and processed output from index.aspx, but mod-mono-server spawns
new childs which are listening on /tmp/mono_server_XXX and will not die.
That is not what I want. I'd like to see a behaviour just like the ASP.NET
ISAPI for IIS: Just one worker process.

Andreas



More information about the Mono-list mailing list