On Sun, 11 Apr 1999, Rich Neill wrote:

> I have Jserv running in standalone/manual mode correcly now, 
> but want to cleanly stop or end Jserv. Does anyone have a
> client which could be used to send the proper terminate
> function over the ajpv11 protocol, port 8007?  The source
> in C or Java would be great. This client would then be
> put into the system shutdown process rather then issuing
> a kill command.

This should be included in some form in the next version of Apache-JServ,
but if you really want the functionality now, source code is at the bottom
of this email. Be warned that the restart function doesn't really work,
just the clean kill.

- donald

import java.io.*;
import java.net.*;
import org.apache.java.net.*;
import org.apache.java.security.*;
import org.apache.java.util.*;
import org.apache.jserv.*;

/**
 * This class issues signals to a running JServ via AJPv1.1. 
 *
 * @author Donald A. Ball Jr.
 * @version 1.0
 */
public class JServSignal {

        public static void main(String argv[]) throws Exception {
                if (argv == null || argv.length == 0) {
                        System.err.println("usage: java JServSignal configFile 
[signal]");
                        System.exit(1);
                }
                String signal = null;
                if (argv.length == 1 || argv[1].equals("15") || 
argv[1].toLowerCase().equals("kill"))
                        signal = "0004s\t150000";
                else if (argv[1].equals("1") || argv[1].equals("01") || 
argv[1].toLowerCase().equals("hup") || argv[1].toLowerCase().equals("restart"))
                        signal = "0004s\t010000";
                else {
                        System.err.println("Unknown signal: "+argv[1]);
                        System.exit(1);
                }
                Configurations confs = new Configurations(new 
ExtendedProperties(argv[0]));
                int port = confs.getInteger("port",JServ.DEFAULT_PORT);
                File f = new File(confs.getString("security.secretKey"));
                InputStream is = new BufferedInputStream(new FileInputStream(f));
                byte[] secret = new byte[is.available()];
                is.read(secret);
                is.close();
                AuthenticatedSocket socket = new 
AuthenticatedSocket("127.0.0.1",port,new MD5(),secret);
                socket.getOutputStream().write(signal.getBytes());
                socket.close();
                System.out.println("Signal sent.");
        }

}



----------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to