Improved debug messages for all MistIn processes, added ability to manually kill MistIn processes.
This commit is contained in:
		
							parent
							
								
									7647430cf3
								
							
						
					
					
						commit
						dcde050143
					
				
					 2 changed files with 20 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -154,10 +154,10 @@ namespace Mist {
 | 
			
		|||
        }
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      DEBUG_MSG(DLVL_DONTEVEN,"Pre-While");
 | 
			
		||||
      DEBUG_MSG(DLVL_DEVEL,"Input for stream %s started", streamName.c_str());
 | 
			
		||||
      
 | 
			
		||||
      long long int activityCounter = Util::bootSecs();
 | 
			
		||||
      while ((Util::bootSecs() - activityCounter) < 10){//10 second timeout
 | 
			
		||||
      while ((Util::bootSecs() - activityCounter) < 10 && config->is_active){//10 second timeout
 | 
			
		||||
        Util::wait(1000);
 | 
			
		||||
        removeUnused();
 | 
			
		||||
        userPage.parseEach(callbackWrapper);
 | 
			
		||||
| 
						 | 
				
			
			@ -169,7 +169,7 @@ namespace Mist {
 | 
			
		|||
        }
 | 
			
		||||
      }
 | 
			
		||||
      finish();
 | 
			
		||||
      DEBUG_MSG(DLVL_DEVEL,"Closing clean");
 | 
			
		||||
      DEBUG_MSG(DLVL_DEVEL,"Input for stream %s closing clean", streamName.c_str());
 | 
			
		||||
      //end player functionality
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,22 +9,24 @@
 | 
			
		|||
#include INPUTTYPE 
 | 
			
		||||
#include <mist/config.h>
 | 
			
		||||
#include <mist/defines.h>
 | 
			
		||||
#include <mist/procs.h>
 | 
			
		||||
 | 
			
		||||
int main(int argc, char * argv[]) {
 | 
			
		||||
  Util::Config conf(argv[0], PACKAGE_VERSION);
 | 
			
		||||
  mistIn conv(&conf);
 | 
			
		||||
  if (conf.parseArgs(argc, argv)) {
 | 
			
		||||
    std::string streamName = conf.getString("streamname");
 | 
			
		||||
    IPC::semaphore playerLock;
 | 
			
		||||
    if(conf.getString("streamname").size()){
 | 
			
		||||
      playerLock.open(std::string("/lock_" + conf.getString("streamname")).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 1);
 | 
			
		||||
    if (streamName.size()){
 | 
			
		||||
      playerLock.open(std::string("/lock_" + streamName).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 1);
 | 
			
		||||
      if (!playerLock.tryWait()){
 | 
			
		||||
        DEBUG_MSG(DLVL_DEVEL, "A player for stream %s is already running", conf.getString("streamname").c_str());
 | 
			
		||||
        DEBUG_MSG(DLVL_DEVEL, "A player for stream %s is already running", streamName.c_str());
 | 
			
		||||
        return 1;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    conf.activate();
 | 
			
		||||
    while (conf.is_active){
 | 
			
		||||
      int pid = fork();
 | 
			
		||||
      pid_t pid = fork();
 | 
			
		||||
      if (pid == 0){
 | 
			
		||||
        playerLock.close();
 | 
			
		||||
        return conv.run();
 | 
			
		||||
| 
						 | 
				
			
			@ -36,15 +38,23 @@ int main(int argc, char * argv[]) {
 | 
			
		|||
      }
 | 
			
		||||
      //wait for the process to exit
 | 
			
		||||
      int status;
 | 
			
		||||
      while (waitpid(pid, &status, 0) != pid && errno == EINTR) continue;
 | 
			
		||||
      while (waitpid(pid, &status, 0) != pid && errno == EINTR){
 | 
			
		||||
        if (!conf.is_active){
 | 
			
		||||
          DEBUG_MSG(DLVL_DEVEL, "Shutting down input for stream %s because of signal interrupt...", streamName.c_str());
 | 
			
		||||
          Util::Procs::Stop(pid);
 | 
			
		||||
        }
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
      //if the exit was clean, don't restart it
 | 
			
		||||
      if (WIFEXITED(status) && (WEXITSTATUS(status) == 0)){
 | 
			
		||||
        DEBUG_MSG(DLVL_MEDIUM, "Finished player succesfully");
 | 
			
		||||
        DEBUG_MSG(DLVL_MEDIUM, "Input for stream %s shut down cleanly", streamName.c_str());
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
      if (DEBUG >= DLVL_DEVEL){
 | 
			
		||||
        DEBUG_MSG(DLVL_DEVEL, "Player exited with errors - stopping because this is a development build.");
 | 
			
		||||
        DEBUG_MSG(DLVL_DEVEL, "Input for stream %s uncleanly shut down! Aborting restart; this is a development build.", streamName.c_str());
 | 
			
		||||
        break;
 | 
			
		||||
      }else{
 | 
			
		||||
        DEBUG_MSG(DLVL_DEVEL, "Input for stream %s uncleanly shut down! Restarting...", streamName.c_str());
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    playerLock.post();
 | 
			
		||||
| 
						 | 
				
			
			@ -53,4 +63,3 @@ int main(int argc, char * argv[]) {
 | 
			
		|||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue