[Mono-devel-list] Mono app x services
A Rafael D Teixeira
rafaelteixeirabr at hotmail.com
Tue Jun 8 14:35:47 EDT 2004
Well, depending on what is needed I would make just a shell script, like:
#!/bin/sh
nohup mono mydaemon.exe > /tmp/mydaemon.log 2>&1 &
Comments: nohup makes it not be killed when the console session terminates
and "2>&1" redirects stderr to stdin what makes it completely silent (all
output goes to the log file).
If needed a more sofisticated construction could follow this Java Daemon
solution
http://www.geocities.com/primacprim/helloworld2001/rpm.html
Best regards,
Rafael "Monoman" Teixeira
Mono Hacker since 16 Jul 2001 - http://www.go-mono.org/
MonoBrasil Founding Member - Membro Fundador do MonoBrasil
http://monobrasil.softwarelivre.org
English Blog: http://monoblog.blogspot.com/
Brazilian Portuguese Blog: http://monoblog.weblogger.terra.com.br/
>From: "Vadim B. Guzev" <vguzev at yandex.ru>
>
>It seems to me that such tasks can be implemented only with the help of
>C++.
>
>For example, you can start mono as a daemon and pass some parameters (.exe
>filename and so on) like this:
>8<------------------------------------------------------------------------------------------------------
>#include <stdio.h>
>#include <unistd.h>
>#include <sys/types.h>
>#include <sys/param.h>
>#include <iostream.h>
>#include <stdlib.h>
>#include <string.h>
>
>int main( int argc, char** argv ) {
> const char* mcsharppath = getenv( "MCSHARPPATH" );
> if ( mcsharppath == NULL || strlen( mcsharppath ) == 0 ) {
> cout << "Error RMS1! MCSHARPPATH variable wasn't set!" << endl;
> return 1;
> }
>
> int len = strlen( mcsharppath ) + 16;
> char* path = new char [len];
> memset( path, 0, len );
> strncat( path, mcsharppath, strlen( mcsharppath ) );
> strncat( path, "/bin/resman.exe\0", 16 );
>
> FILE* ptr;
> char filename[1024];
>
> if ( (ptr = popen("which mono", "r")) != NULL ) {
> if ( fgets( filename, 1024, ptr ) == NULL ) {
> cout << "Error RMS2! No \"mono\" was found on this system!" << endl;
> cout << " You should probably make sure that Mono wass properly
>installed on your system!" << endl;
> cout << " Also, check you should check your $PATH environment variable
>and " << endl;
> cout << " make sure that \"mono\" interpreter is located in one of the
>specified directories." << endl;
> return 2;
> }
> }
> pclose( ptr );
> pid_t pid;
>
> int i;
>
> for ( int i = 0; i < NOFILE; i++ )
> close( i );
>
> pid = fork();
>
> if ( pid < 0 )
> printf ( "Error RMS3! Fork returned error...\n" );
> else if ( pid > 0 ) {
> exit( 0 );
> }
> else {
> setsid();
>
> char* buf = new char [strlen( filename ) - 1];
> strncpy( buf, filename, strlen( filename ) - 1 );
>
> execl( buf, "mono",
> (const char*) path, argv [1],
> (char *)0 );
> perror( "Error RMS4! Execl failed in the rm_starter child...\n" );
> exit( 1 );
> }
>}
>
>8<------------------------------------------------------------------------------------------------------
>
>I couldn't find any way how to implement such things in pure C#. Is it
>possible at all?
>
>
>Best regards,
>Vadim B. Guzev
>http://u.pereslavl.ru/~vadim/MCSharp/
> ----- Original Message -----
> From: Pekus Cons. e Desenvolvimento
> To: mono-devel-list at lists.ximian.com
> Sent: Tuesday, June 08, 2004 9:45 PM
> Subject: [OBORONA-SPAM] [Mono-devel-list] Mono app x services
>
>
> Hi,
>
> Did anyone try to use a mono app like a linux service (i.e.: load the
>app like a daemon)? In affirmative case, could you please give an
>orientation?
>
> Regards,
>
> Baccarin.
_________________________________________________________________
MSN Messenger: instale grátis e converse com seus amigos.
http://messenger.msn.com.br
More information about the Mono-devel-list
mailing list