0

How to check if server is up and responding

Posted by sanjay on 3:33 PM in
// todo launch server
Thread executeThread = new Thread(this);
executeThread.setPriority(Thread.NORM_PRIORITY);
executeThread.start();
int port = 8080

String host = "localhost";
int sleepCount = 0;
boolean doLoop = true;
while (doLoop) {
try {
logEvent(this,Log.DBG,"..Creating Socket ");
Socket sock = new Socket (host,port);
logEvent(this,Log.DBG,"..Connected to Server");
// test code ...
PrintWriter out = new PrintWriter (sock.getOutputStream(),true);
BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
out.println("GET /index.jsp HTTP/1.1");
out.println("Host: " + host + ":" + port);
out.println("Connection: Close");
out.println();
while (doLoop){
if (in.ready()){
sock.close();
doLoop = false;
break;
} else {
try {
Thread.currentThread().sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

} catch (IOException e) {
logEvent(this,Log.WARNING,"..Unable to connect");
if (sleepCount==120) {
logEvent(this,Log.WARNING,".. proceeding without connection to " + host + " at " + port);
break;
}
logEvent(this,Log.DBG,"..About to sleep for 5 seconds");
try {
Thread.sleep(5000);
}catch (InterruptedException ie) {
logEvent(this,Log.WARNING,"..InterruptedException on main thread:" + ie);
}
logEvent(this,Log.DBG,"..Waking up after 5 seconds");
sleepCount++;
}

}
try {
// sleep 90 seconds for the server to finish startup
Thread.sleep(1000);
} catch (InterruptedException e ) {
logEvent(this,Log.DBG,e.toString());
}
logEvent(this,Log.DBG,"..server is up");
return true;
}

public void run() {
String startupScript = hubDeployer.getStartupScript();
String[] args = null;
String logFolder = logFolder
try {

ps = new ProcessExec(SHELL_COMMAND, args, outputFile, outputFile);
ps.executeProcess();

} catch (Exception e) {
logEvent(this, Log.ERROR, "Failed to execute " + installScript);
logEvent(this, Log.ERROR, e);
}
}


}

0

Hard disk power management explained ..

Posted by sanjay on 2:23 AM in
here

spinning down usb hard disk for nslu2 --> here

0

ProFont? or which font

Posted by sanjay on 7:02 PM in
Like ProFont? I do. Do you like it so much that you'd like to use it for your cmd prompt? Well... if you use windows, that is :)

I also came across this list.. where you can choose your font!!

0

Need help with Ubuntu?

Posted by sanjay on 10:00 AM in
Well, you can contact me! or just refer to the Ubuntu Guide wiki. It seems pretty comprehensive

0

An introduction to patterns

Posted by sanjay on 1:14 AM in
I just came across Brad Appleton's Introduction to Patterns. Don't know how i missed it earlier, but I'm glad I came across it. It provides a nice brief intro

0

GVIM Tips

Posted by sanjay on 7:43 PM in
I just came across David Rayner's gvim tip page. It seems comprehensive. I just discovered :e .

Good!!

Also check the Vi Lovers Home Page. Yeah, true love, for some :)

And then there is Vim-shell. Check this page for details.. maybe you'll be all set. I haven't tried this yet

Use svk? then try svk.vim

Copyright © 2009 Note my web All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive.