[Mono-list] mono-service doesn't start my service - no errors
jcmag
jcmag at yahoo.com
Sat Jan 20 15:36:57 EST 2007
Hi,
I've developped a Service that works on Windows. I'm trying to use it on Linux (Ubuntu 6.10), with the following command:
bash mono-service MyHal.Service.exe
but my service doesn't seem to start. I have no error messages, except:
Jan 20 21:17:47 mylaptop mono: MyHal.Service.exe: Log file already exists: /tmp/MyHal.Service.exe.lock
(when I re-run the command several times)
Here is my main function:
static class Program
{
static void error (string prefix, string format, params object [] args)
{
Mono.Unix.Native.Syscall.syslog (Mono.Unix.Native.SyslogLevel.LOG_ERR, String.Format ("{0}: {1}", prefix, String.Format (format, args)));
}
static void Main()
{
error("Main1", "Begin");
ServiceBase.Run(new ServiceBase[] { new MyHal.Service.Service1() });
error("Main1", "End");
}
}
(in syslog I see only the "Begin" message)
and here is my service:
public class Service1 : ServiceBase
{
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public const string MyServiceName = "MyHal";
static void error (string prefix, string format, params object [] args)
{
Mono.Unix.Native.Syscall.syslog (Mono.Unix.Native.SyslogLevel.LOG_ERR, String.Format ("{0}: {1}", prefix, String.Format (format, args)));
}
static Service1()
{
error("Service1", "static constructor!!!");
Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
}
public Service1()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.ServiceName = MyServiceName;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
protected override void OnStart(string[] args)
{
try
{
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));
MyHal.Engine.Core.Instance.Init();
}
catch (Exception exc)
{
_log.Fatal("Exception : " + exc.Message);
throw;
}
}
protected override void OnStop()
{
try
{
MyHal.Engine.Core.Instance.Shutdown();
}
catch (Exception exc)
{
_log.Fatal("Exception : " + exc.Message);
throw;
}
}
}
(the "static constructor!!!" message doesn't appear in syslog)
I am a Linux beginner so I don't know what to do now.
I've also another question: after the call to mono-service, the service is installed on the machine and will be executed, or do we have to do something for that?
Thanks in advance
JC
--------------------
http://sourceforge.net/projects/myhal
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20070120/79fdf207/attachment.html
More information about the Mono-list
mailing list