Search code examples
linuxmononancysupervisordspark-view-engine

How to set path to Mono so Supervisor knows about it?


I am following this tutorial (Hosting Nancy with Nginx on Ubuntu) with one change. I am using the Spark view engine instead of the built in view engine.

Spark view engine throws an error building any view when the Nancy host is running under supervisor.

    System.SystemException: Error running mcs: Cannot find the specified file
at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters,string[]) <0x00577>
at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters,string[]) <0x00033>
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters,string[]) <0x0004d>
at Spark.Compiler.BatchCompiler.Compile (bool,string,string[]) <0x007f4>
at Spark.Compiler.CSharp.CSharpViewCompiler.CompileView (System.Collections.Generic.IEnumerable`1>,System.Collections.Generic.IEnumerable`1>) <0x00087>
at Spark.SparkViewEngine.CreateEntryInternal (Spark.SparkViewDescriptor,bool) <0x002af>
at Spark.SparkViewEngine.CreateEntry (Spark.SparkViewDescriptor) <0x0004f>
at Nancy.ViewEngines.Spark.SparkViewEngine/<>c__DisplayClass2.b__1 (Nancy.ViewEngines.ViewLocationResult) <0x00023>
at Nancy.ViewEngines.DefaultViewCache/<>c__DisplayClass1`1.b__0 (Nancy.ViewEngines.ViewLocationResult) <0x00023>

If I run the environment setting script /opt/mono/env.sh and then run my host from the command prompt, the website works.

I think it must be due to my Nancy host not being able to find Mono when running under supervisor.

For reference:

#env.sh
export PATH=/opt/mono/bin:$PATH
export LD_LIBRARY_PATH=/opt/mono/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig:$PKG_CONFIG_PATH

I am using Mono 3.8.0 from here: http://download.opensuse.org/repositories/home:/tpokorra:/mono/xUbuntu_14.04/

How do I set these paths so that Nancy host can find Mono when running under supervisor?


Solution

  • I needed to set the environment option in my supervisor configuration file.

    Here is the setting that worked for the above example.

    environment=PATH="/opt/mono/bin:$PATH"