Mantis - Resin
Viewing Issue Advanced Details
307 minor always 07-12-05 00:00 11-30-05 14:43
ferg  
 
urgent  
closed 3.0.14  
3.0.14 fixed  
none    
none 3.0.15  
0000307: Resin Daemon enhancement
RSN-350
(rep by Fiaz Hossain)

 The problem with the current daemon mode is that there seems to be no way to shutdown the resin process. The only option is to be able to restart it which is not ideal. What I added was to flag to ResinServer to mark it for shutdown.
 

Notes
(0000346)
ferg   
07-12-05 00:00   
1. Shutdown a Resin Daemon server. Priority - Very High. We have built a JMX based monitoring and management infrastructure that allows us to manage servers more effectively that wrapper.pl. We are basically running our servers in "daemon" mode as opposed to have the socket based shutdown mode that the wrapper.pl employs. This allows us to restart the monitor (wrapper.pl) without restarting the application server. The problem with the current daemon mode is that there seems to be no way to shutdown the resin process. The only option is to be able to restart it which is not ideal. What I added was to flag to ResinServer to mark it for shutdown.
 
File1 - com.caucho.server.resin.ResinServer.java.
 
+ private boolean _isClosingForShutdown;
 
+ /**
+ * Returns true if the server is closing for shutdown.
+ */
+ public boolean isClosingForShutdown()
+ {
+ return _isClosingForShutdown;
+ }
 
+ /**
+ * Set closing for shutdown.
+ */
+ public void setClosingForShutdown()
+ {
+ _isClosingForShutdown = true;
+ }
 
Also currently there is a race condition, where the server is marked _isClosed but not all close events have been called. This _isClosed is picked up by Resin.java that tries to shutdown the server when another thread calls closeEvent and tries to restart the server. The fix to the race condition is to change the finally of the destroy method to look like this:
 
    } finally {
        try {
            ArrayList<ResinServerListener> listeners = _listeners;
           
            for (int i = 0; i < listeners.size(); i++) {
                ResinServerListener listener = listeners.get(i);
   
                listener.closeEvent(this);
            }
        } finally {
            _isClosed = true;
        }
    }
 
File2 - com.caucho.server.resin.Resin.java
 
Original CloseEvent()
  public void closeEvent(ResinServer server)
  {
    try {
      if (_waitIn == null) {
            _isRestarting = true;
            _server = null;
 
            log.info("restarting Resin");
 
            init();
      }
      else
            _isClosed = true;
    } catch (Throwable e) {
      _isClosed = true;
      log.log(Level.WARNING, e.toString(), e);
    }
  }
 
Should be modified to include serveris.isClosingForShutdown() as shown below
 
  public void closeEvent(ResinServer server)
  {
    try {
      if (_waitIn == null) {
          if (server != null && !server.isClosingForShutdown()) {
            _isRestarting = true;
            _server = null;
 
            log.info("restarting Resin");
 
            init();
    _isRestarting = false;
          }
          // For the shutdown case there is nothing to do
      }
      else
            _isClosed = true;
    } catch (Throwable e) {
      _isClosed = true;
      log.log(Level.WARNING, e.toString(), e);
    }
  }
 
 
(0000347)
ferg   
07-12-05 00:00   
Using setRestartOnClose(boolean) as the attribute name.