W
Will
I've got a java service under solaris which runs in the background
(command line based). When I start the application it runs and
periodically executes some stuff.
Questions:
==========
1. Is there an easy and quick way to stop the application/service
instead of killing the process from within the shell (which is not
really nice).
2. How can I stop it using java code?
Is there any other way than listening to a socket or monitoring a file
for some kind of shutdown command? (interprocess communication)
2. How can I avoid that more than one instance of the application run
at the same time?
Here's the code I use so far:
=============================
public final class NuevMailTimer extends TimerTask{
public static void main(String[] args) {
if (args.length!=1) {
System.out.println("ERROR: Missing argument");
System.out.println("Usage: XXXX -start|stop");
System.exit(1);
}
if (args[0].trim().toLowerCase().equals("-stop")) {
System.out.println("stopped!");
// WHAT TO PUT IN HERE??
}
if (!args[0].trim().toLowerCase().equals("-start")) {
System.out.println("ERROR: Unknown argument");
System.out.println("Usage: XXXX -start|stop");
System.exit(1);
}
...
Long pollInterval = new Long(poll_interval);
final long TIMER_INTERVAL = pollInterval.longValue();
TimerTask tTask = new NuevMailTimer();
Timer myTimer = new Timer();
myTimer.scheduleAtFixedRate(tTask, 0, TIMER_INTERVAL);
}
public void run() {
...
}
}
Will
(command line based). When I start the application it runs and
periodically executes some stuff.
Questions:
==========
1. Is there an easy and quick way to stop the application/service
instead of killing the process from within the shell (which is not
really nice).
2. How can I stop it using java code?
Is there any other way than listening to a socket or monitoring a file
for some kind of shutdown command? (interprocess communication)
2. How can I avoid that more than one instance of the application run
at the same time?
Here's the code I use so far:
=============================
public final class NuevMailTimer extends TimerTask{
public static void main(String[] args) {
if (args.length!=1) {
System.out.println("ERROR: Missing argument");
System.out.println("Usage: XXXX -start|stop");
System.exit(1);
}
if (args[0].trim().toLowerCase().equals("-stop")) {
System.out.println("stopped!");
// WHAT TO PUT IN HERE??
}
if (!args[0].trim().toLowerCase().equals("-start")) {
System.out.println("ERROR: Unknown argument");
System.out.println("Usage: XXXX -start|stop");
System.exit(1);
}
...
Long pollInterval = new Long(poll_interval);
final long TIMER_INTERVAL = pollInterval.longValue();
TimerTask tTask = new NuevMailTimer();
Timer myTimer = new Timer();
myTimer.scheduleAtFixedRate(tTask, 0, TIMER_INTERVAL);
}
public void run() {
...
}
}
Will