Wednesday, 14 August 2013

Mono versions and fast cgi

A quick note on mono versions and fastcgi-mono-server4


These versions seems to work together well: (With 2.11 being outdated, and in fact never having been released, I would recommend the 3.0.x series. I am using 3.0.7 at present.)



Mono 2.11.4 - git 1723480147411f3973ebceba66f518db69131d10
xsp - git 6365230e6ef348045078f477af085429dceedb3d

File: /etc/systemd/system/fcgimono.service
[Unit]
Description=Mono fcgi Server
Before=nginx.service
After=nss-user-lookup.target

[Service]
EnvironmentFile=
Type=simple
ExecStart=<mono_path>/fastcgi-mono-server4 \
--applications=*:<port>:/:/<app_path> \
--socket=unix --filename=/tmp/fcgimono.sock --verbose=true \
--loglevel=All
User=http
Group=http

[Install]
WantedBy=multi-user.target




Mono 3.0.6 - git 20e40c448cedb603f8c1bdf2b29ffc4d43b721b6
Mono 3.0.7 - git 514fcd79208764c170851c61498d650dc357b429
Mono 3.0.11 - git 6df55cf92a314af75c2723ff9a1f3c4128c52dfd
xsp - git 4587438369691b9b3e8415e1f113aa98b57d1fde

File: /etc/systemd/system/fcgimono.service
(as above)



The below DOES NOT work, and serves blank pages. Might be a simple fix
but I have not looked at it yet.
Mono 3.2.1 - git f3f789e7f826ea9077564c35a0a6e38f09e4c664
xsp - git ae70e0355edf5ac91cb9aa81a0d1075cda62c384

File: /etc/systemd/system/fcgimono.service
(note below syntax change)
ExecStart=/fastcgi-mono-server4 \
/applications=*:8083:/:/ \
/socket=unix /filename=/tmp/fcgimono.sock /verbose=true \
/loglevel=All


One final note - if you are installing on a parallel development environment, then under some circumstances, the path the the fastcgi executable is not built correctly. The below example demonstrates:



File: /opt/mono/bin/fastcgi-mono-server4
#!/bin/sh
- exec /usr/bin/mono $MONO_OPTIONS "/opt/mono/lib/mono/4.5/fastcgi-mono-server4.exe" "$@"
+ exec /opt/mono/bin/mono $MONO_OPTIONS "/opt/mono/lib/mono/4.5/fastcgi-mono-server4.exe" "$@"


Oh, and before I forget:



The parallel environment file needs export statements
(even though systemd complains) or else the web app breaks.
Example:

File: /opt/mono/etc/mono_dev-env
#!/bin/bash
MONO_PREFIX=/opt/mono
MONO_OPTIONS="--debug"
export DYLD_LIBRARY_FALLBACK_PATH=$MONO_PREFIX/lib:$DYLD_LIBRARY_FALLBACK_PATH
export LD_LIBRARY_PATH=$MONO_PREFIX/lib:usr/lib
export C_INCLUDE_PATH=$MONO_PREFIX/include:/usr/include
export ACLOCAL_PATH=$MONO_PREFIX/share/aclocal:/usr/share/aclocal
export PKG_CONFIG_PATH=$MONO_PREFIX/lib/pkgconfig:/usr/lib/pkgconfig
export PATH=$MONO_PREFIX/bin:$PATH
export MONO_GAC_PREFIX=$MONO_PREFIX:/usr
PS1="[mono] \w @ "

if you are going to be switching environments, then these variables need to be
reset. Like so:

File: /etc/profile.d/mono.sh
MONO_PREFIX=/usr

#unset parallel mono environment
export MONO_GAC_PREFIX=$MONO_PREFIX
export DYLD_LIBRARY_FALLBACK_PATH=`echo ${DYLD_LIBRARY_FALLBACK_PATH} | awk -v RS=: -v ORS=: '/opt/ {next} {print}$
export LD_LIBRARY_PATH=`echo ${LD_LIBRARY_PATH} | awk -v RS=: -v ORS=: '/opt/ {next} {print}' | sed 's/:*$//'`
export C_INCLUDE_PATH=`echo ${C_INCLUDE_PATH} | awk -v RS=: -v ORS=: '/opt/ {next} {print}' | sed 's/:*$//'`
export ACLOCAL_PATH=`echo ${ACLOCAL_PATH} | awk -v RS=: -v ORS=: '/opt/ {next} {print}' | sed 's/:*$//'`
export PKG_CONFIG_PATH=`echo ${PKG_CONFIG_PATH} | awk -v RS=: -v ORS=: '/opt/ {next} {print}' | sed 's/:*$//'`
export PATH=`echo ${PATH} | awk -v RS=: -v ORS=: '/opt/ {next} {print}' | sed 's/:*$//'`



And a mono / libgdiplus compilation note:



MONO libgdiplus needs giflib 4.x - won't compile with giflib 5.x.
If in a bind, you can compile libgdiplus without gif support.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.