mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
(trunk daemon) add pidfile support to transmission-daemon
This commit is contained in:
parent
fcc56ddcd5
commit
26fe593048
1 changed files with 24 additions and 12 deletions
|
@ -43,6 +43,7 @@
|
||||||
static tr_bool paused = FALSE;
|
static tr_bool paused = FALSE;
|
||||||
static tr_bool closing = FALSE;
|
static tr_bool closing = FALSE;
|
||||||
static tr_session * mySession = NULL;
|
static tr_session * mySession = NULL;
|
||||||
|
static const char * pid_filename = NULL;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
**** Config File
|
**** Config File
|
||||||
|
@ -100,6 +101,7 @@ static const struct tr_option options[] =
|
||||||
{ 'r', "rpc-bind-address", "Where to listen for RPC connections", "r", 1, "<ipv4 address>" },
|
{ 'r', "rpc-bind-address", "Where to listen for RPC connections", "r", 1, "<ipv4 address>" },
|
||||||
{ 953, "global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio", "gsr", 1, "ratio" },
|
{ 953, "global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio", "gsr", 1, "ratio" },
|
||||||
{ 954, "no-global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio", "GSR", 0, NULL },
|
{ 954, "no-global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio", "GSR", 0, NULL },
|
||||||
|
{ 'x', "pid-file", "Enable PID file", "x", 1, "<pid-file>" },
|
||||||
{ 0, NULL, NULL, NULL, 0, NULL }
|
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -401,17 +403,19 @@ main( int argc, char ** argv )
|
||||||
case 'r':
|
case 'r':
|
||||||
tr_bencDictAddStr( &settings, TR_PREFS_KEY_RPC_BIND_ADDRESS, optarg );
|
tr_bencDictAddStr( &settings, TR_PREFS_KEY_RPC_BIND_ADDRESS, optarg );
|
||||||
break;
|
break;
|
||||||
case 953:
|
case 953:
|
||||||
tr_bencDictAddReal( &settings, TR_PREFS_KEY_RATIO, atof(optarg) );
|
tr_bencDictAddReal( &settings, TR_PREFS_KEY_RATIO, atof(optarg) );
|
||||||
tr_bencDictAddBool( &settings, TR_PREFS_KEY_RATIO_ENABLED, TRUE );
|
tr_bencDictAddBool( &settings, TR_PREFS_KEY_RATIO_ENABLED, TRUE );
|
||||||
break;
|
break;
|
||||||
case 954:
|
case 954:
|
||||||
tr_bencDictAddBool( &settings, TR_PREFS_KEY_RATIO_ENABLED, FALSE );
|
tr_bencDictAddBool( &settings, TR_PREFS_KEY_RATIO_ENABLED, FALSE );
|
||||||
break;
|
break;
|
||||||
case 'y': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LPD_ENABLED, TRUE );
|
case 'x': pid_filename = optarg;
|
||||||
break;
|
break;
|
||||||
case 'Y': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LPD_ENABLED, FALSE );
|
case 'y': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LPD_ENABLED, TRUE );
|
||||||
break;
|
break;
|
||||||
|
case 'Y': tr_bencDictAddBool( &settings, TR_PREFS_KEY_LPD_ENABLED, FALSE );
|
||||||
|
break;
|
||||||
default: showUsage( );
|
default: showUsage( );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -447,6 +451,14 @@ main( int argc, char ** argv )
|
||||||
tr_ninf( NULL, "Using settings from \"%s\"", configDir );
|
tr_ninf( NULL, "Using settings from \"%s\"", configDir );
|
||||||
tr_sessionSaveSettings( mySession, configDir, &settings );
|
tr_sessionSaveSettings( mySession, configDir, &settings );
|
||||||
|
|
||||||
|
if( pid_filename != NULL ) {
|
||||||
|
FILE * fp = fopen( pid_filename, "w+" );
|
||||||
|
if( fp != NULL ) {
|
||||||
|
fprintf( fp, "%d", (int)getpid() );
|
||||||
|
fclose( fp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( tr_bencDictFindBool( &settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED, &boolVal ) && boolVal )
|
if( tr_bencDictFindBool( &settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED, &boolVal ) && boolVal )
|
||||||
tr_ninf( MY_NAME, "requiring authentication" );
|
tr_ninf( MY_NAME, "requiring authentication" );
|
||||||
|
|
||||||
|
@ -478,7 +490,7 @@ main( int argc, char ** argv )
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG
|
#ifdef HAVE_SYSLOG
|
||||||
if( !foreground )
|
if( !foreground )
|
||||||
openlog( MY_NAME, LOG_CONS, LOG_DAEMON );
|
openlog( MY_NAME, LOG_CONS|LOG_PID, LOG_DAEMON );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while( !closing ) {
|
while( !closing ) {
|
||||||
|
|
Loading…
Reference in a new issue