Changeset 2109:0b8deb4a879d in roaraudio


Ignore:
Timestamp:
07/22/09 15:14:12 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added --start/--stop/--shutdown (socket/protocol based)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/roard.c

    r2106 r2109  
    4242        " --daemon              - Bring the server into background after init\n" 
    4343        " --terminate           - Terminate after last client quited\n" 
     44        " --start               - No op parameter (starting roard is default operation)\n" 
    4445        " --restart             - Trys to stop an old instance and start a new with new settings\n" 
     46        " --stop                - Stops a running roard (provide --pidfile!)\n" 
     47        " --shutdown            - Terminates a running roard (provide --pidfile!)\n" 
    4548        " --realtime            - Trys to get realtime priority,\n" 
    4649        "                         give multible times for being more realtime\n" 
     
    135138#endif 
    136139 
    137 int restart_server (char * server) { 
     140int restart_server (char * server, int terminate) { 
    138141 struct roar_connection con; 
     142 
    139143 if ( roar_connect(&con, server) == -1 ) { 
    140144  return -1; 
    141145 } 
    142146 
    143  if ( roar_terminate(&con, 1) == -1 ) { 
     147 if ( roar_terminate(&con, terminate) == -1 ) { 
    144148  return -1; 
    145149 } 
     
    622626   return 0; 
    623627 
     628  } else if ( strcmp(k, "--start") == 0 ) { 
     629   // this is a no op 
    624630  } else if ( strcmp(k, "--restart") == 0 ) { 
    625631#ifdef ROAR_SUPPORT_LISTEN 
    626    if ( restart_server(server) == -1 ) { 
     632   if ( restart_server(server, 1) == -1 ) { 
    627633    ROAR_WARN("Can not terminate old server (not running at %s?), tring to continue anyway", server); 
    628634   } 
     
    630636   ROAR_ERR("--restart not supported"); 
    631637#endif 
     638  } else if ( strcmp(k, "--shutdown") == 0 ) { 
     639#ifdef ROAR_SUPPORT_LISTEN 
     640   if ( restart_server(server, 1) == -1 ) { 
     641    ROAR_WARN("Can not terminate old server (not running at %s?)", server); 
     642    return 1; 
     643   } 
     644   return 0; 
     645#else 
     646   ROAR_ERR("--shutdown not supported"); 
     647   return 1; 
     648#endif 
     649  } else if ( strcmp(k, "--stop") == 0 ) { 
     650#ifdef ROAR_SUPPORT_LISTEN 
     651   if ( restart_server(server, 1) == -1 ) { 
     652    ROAR_WARN("Can not stop old server (not running at %s?)", server); 
     653    return 1; 
     654   } 
     655   return 0; 
     656#else 
     657   ROAR_ERR("--stop not supported"); 
     658   return 1; 
     659#endif 
     660 
    632661 
    633662  } else if ( strcmp(k, "--demon") == 0 || strcmp(k, "--daemon") == 0 ) { 
Note: See TracChangeset for help on using the changeset viewer.