How to start and stop a server
I am doing some sockets programming.
Now, when I want to get the TomCat 4 server running for instance, I would have to run the startup.bat or startup.sh file. To stop the server I run the shutdown.bat or shutdown.sh file.
Can I do the same thing in Java?
That is, in one window, I run a program: C:\>java myserver start
The server starts running and holds there.
In another window, I run another command: C:\>java myserver stop
and the server in the other window stops.
I am thinking the server would be running in a thread. When I shut it down, I close the thread just like in the Applet Clock example.
I've tried this but it doesn't work.
Can anyone please advise.
Thanks.
Anthony.
Not precisely that way, but just off the top of my head, you would have to have a handle to the proccess (server) in the first window, then have a monitor program that allows you take this handle and end it. I would make this monitor program be the gateway to starting and stopping your server. To run a .bat file you can use runtime.exec().
Similar Messages
-
How to Starting and Stopping OC4J Server using Ant
How to Starting and Stopping OC4J Server using Ant
In the ant task definitions for ant-oracle-classes.jar (see antlib.xml) there are two tasks called
name="restartServer" classname="oracle.ant.taskdefs.deploy.JSR88StartServer"
name="shutdownServer" classname="oracle.ant.taskdefs.deploy.JSR88ShutdownServer"
I thought that these would shutdown and start the OC4J server. I guessed the parameters as – (Does anyone know where 50 ant targets are documented?)
<oracle:restartServer
userid="${oc4j.admin.user}"
password="${oc4j.admin.password}"
deployeruri="${deployer.uri}"
/>
<oracle:shutdownServer
userid="${oc4j.admin.user}"
password="${oc4j.admin.password}"
deployeruri="${deployer.uri}"
/>
This, however does not start and stop the SOA suite. To do that I've hacked this solution together -
<path id="oc4j.console">
<pathelement location="${oracle.home}/config"/>
<pathelement location="${oracle.home}/jlib/startupconsole.jar"/>
<pathelement location="${oracle.home}/opmn/lib/optic.jar"/>
<pathelement location="${oracle.home}/lib/xmlparserv2.jar"/>
</path>
<target name="stop" description="stop oc4j server" depends="init">
<java classname="oracle.appserver.startupconsole.view.Runner">
<classpath refid="oc4j.console"/>
<sysproperty key="ORACLE_HOME" path="${oracle.home}"/>
<arg value="stop"/>
</java>
</target>
<target name="start" description="restart oc4j server" depends="init">
<java classname="oracle.appserver.startupconsole.view.Runner">
<classpath refid="oc4j.console"/>
<sysproperty key="ORACLE_HOME" path="${oracle.home}"/>
<arg value="start"/>
</java>
</target>
This sort of works – except when the SOA suite doesn't stop cleanly – and needs user interaction to press a Close button. This isn't very useful when doing a continous integration build and deploy.
So, does anyone have any suggestions or alternative methods to do this?
- frankActually if the server throws exceptions when it stops (which it always has since we applied patch 10.1.3.3) this technique will pause until a user responds to pop-up ... So a better way (I think) is -
<target name="start" description="start oc4j server" depends="init">
<java classname="oracle.appserver.startupconsole.view.Runner">
<classpath refid="oc4j.console"/>
<sysproperty key="ORACLE_HOME" path="${oracle.home}"/>
<arg value="start"/>
</java>
</target>
<target name="stop" description="stop oc4j server" depends="init">
<echo message="We expect OC4J *NOT* to stop cleanly, so we will timeout after 3 minutes ..."/>
<java classname="oracle.appserver.startupconsole.view.Runner" fork="true" timeout="180000">
<classpath refid="oc4j.console"/>
<sysproperty key="ORACLE_HOME" path="${oracle.home}"/>
<arg value="stop"/>
</java>
</target>
<target name="restart" description="restart oc4j server">
<antcall target="stop"/>
<!-- wait for server to quieten down -->
<waitfor maxwait="2" maxwaitunit="minute">
<not><http url="http://${oc4j.http.hostname}:${oc4j.http.port}"/></not>
</waitfor>
<antcall target="start"/>
</target> -
How to start and stop sapmmc server when windows is started and shutdown
Hi,
May i know how i can make sure the sapmmc server for ECC 6.0 to start when the windows 2003 server is started. I know i need to add this as a service in the windows service manager but i dont know how to do that.
Please advise me on how to add a service to start the sapmmc server when windows is started and how to stop the sapmmc server automatically when windows is shutdown.Hi Raja
checkout this document m sure it will help you in configuration
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/0512c790-0201-0010-72b7-886677ad7955
also check
/message/6511605#6511605 [original link is broken]
All the best ,,
Cheers
dEE -
How to start and stop Oracle Application Server from ANT
How to start and stop Oracle Application Server and Web application from ANT
Thanks in Advance.
ManiHi,
You can use: startManagedWebLogic.sh, it is in your domain directory and you have to execute it in this way
./startManagedWebLogic.sh managedServerName http://adminServerHost:adminServerPort
For instance, in my case I use:
unixserv01:/webportal/domains/appServerWeb/bin>startManagedWebLogic.sh managedServ01 http://pelma3w3per01.mesaperu.next:7001
You have to run it on the machine where the managed server was installed.
Best regards,
Raúl -
How to Start and Stop Processes?
How to Start and Stop Processes?
Im trying to create a program which allows me to Start and Stop (and Restart) GameServers. I will then expand on this so i can start and stop them through a web applet with build in useraccounts.
Currently the way we do this is to log into the server using a RemoteAssistance. Which is not very safe as the users have the abbility to do anything on the server and potentially corrupt it.
Below is my code for how i start the servers. But i dont know how i would stop the process.
private void startServers()
for(GameServer gs : servers)
int ID = Integer.parseInt(gs.getID());
if(isChecked(ID))
try
String cmd[] = gs.getStartString();
Runtime.getRuntime().exec(cmd);
int sleepPeriod = Integer.parseInt(sleepField.getText());
Thread.sleep(sleepPeriod*100);
catch(Exception e)
System.out.println(e);
}//end of iterator
JOptionPane.showMessageDialog(null,"All Selected Servers Have been started.","Servers Started",2);
}//end of startserversAnyhelp would be great thanks.Using the process class would give you a nicer API, but using destroy isn't a nice way to shutdown a process. Its like killing the process with your task manager. You should make a connection in some way with the game server and tell it to shutdown in stead (gracefull termination).
-
How to start and stop a progress-bar thread before/after the main thread
hi. I would appreciate any kind of help on my request.
I have this as my main() function
public static void main(String[] args)
SwingUtilities.invokeLater(new Runnable(){
public void run(){
Options op = new Options();
OdessaClient oc = new OdessaClient(op);
oc.setVisible(true);
}Whenever I try to start a simple JFrame with an indeterminate progress bar on it just before the main function and stop it somewhere after I get a StackOverFlow error
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
at java.awt.Component.show(Component.java:1302)
at java.awt.Component.setVisible(Component.java:1253)
at com.client.CylonBar.hide(CylonBar.java:25)
at java.awt.Component.show(Component.java:1302)
at java.awt.Component.setVisible(Component.java:1253)
...and so on...How must I implement something like it?Not precisely that way, but just off the top of my head, you would have to have a handle to the proccess (server) in the first window, then have a monitor program that allows you take this handle and end it. I would make this monitor program be the gateway to starting and stopping your server. To run a .bat file you can use runtime.exec().
-
How to start and stop the BI Services in Solaris 10
Hello All,
Can anyone guide me on how to start and stop the BI Services in Solaris 10. In windows there are options set in Start->Programs->Middleware_Home->Start/Stop BI Services.
Primarily after doing changes to the scheduler configuration, I need to restart the services to get it implemented? If yes how can I do it?
Any help will be appreciated
Thank you
Ash
Edited by: 902739 on Jan 11, 2012 12:17 PMPlease help me by showing action plan for stop sap , offline backup and then start sap.
i am little bit confuse How to start and stop SAP on cluster for offline backup
Below are the systems name with host name , please explain me in sequence
Systems name Hostname
# Hope SAP ERP Prod DB Primary gsgbbux860
# Hope SAP ERP Prod DB Standby gsgbbux861
# Hope SAP ERP Prod Cluster gsgbbux862
# Hope SAP ERP App 1 gsgbbux864
# Hope SAP ERP App 2 gsgbbux865
Thanks in advance
Zaheer -
How to Start and Stop the SAP System
Hi,
I have installed "Sneak Preview"; Searched for start and stop scripts but there are more than one script which has named start.bat and stop.bat. Moreover, I searched the documents which comes with Sneak Preview but could find useful instruction there either.
Question: Could you please point me to the documentation where it explains the starting and stopping SAP, for Sneak Preview?
Thanks in advance
Jawad KakarPlease help me by showing action plan for stop sap , offline backup and then start sap.
i am little bit confuse How to start and stop SAP on cluster for offline backup
Below are the systems name with host name , please explain me in sequence
Systems name Hostname
# Hope SAP ERP Prod DB Primary gsgbbux860
# Hope SAP ERP Prod DB Standby gsgbbux861
# Hope SAP ERP Prod Cluster gsgbbux862
# Hope SAP ERP App 1 gsgbbux864
# Hope SAP ERP App 2 gsgbbux865
Thanks in advance
Zaheer -
How to start and stop VIO cluster
How to start and stop VIO cluster
How to extend/modify the VIO cluster once created from webclient
Thanks,
VenkatVIO 1.0 GA version has the UI to start/stop the cluster
-
How to start and stop a queue in ECC??
Dear all,
I have a problem regarding the Start and Stop of queues in ECC. Whenever I change the data in ECC (for example extension of a material to a new distribution chain, or Creating a quotation which has to trigger a corresponding quotation in CRM), replication is not happening to CRM. On analysis of the outbound queue in ECC, we are finding corresponding ernties for the material / quotation. On dbl cliking an entry, we are able to see the queue in STOP status. When tried to reset status and activate, system throws a message saying GENERIC STOP SET.
1) How to overcome this problem?
2) How to START or STOP a queue (for Eg: R3AD*) in ECC?
Please respond.
Every point you share will fetch so many points / lot many smiles to you (No surprises.. I am plagerizing the famous quote on SDN)
Regards,
RajeshDear Chandra,
Thanks for ur quick response. I have awarded you a sixer. Ofcourse, the content is much richer than that. But if i award 10, thread has to be closed. So that stopped me from awarding that
Dear all,
Can someone else share their views?
Regards,
Rajesh -
I'm very new to Flash / action script, so I just need to know where to put both the start loop, and the end loop code (below) in my Flash file to make the waving effect on this flag (link below) start and stop when I need it to, because I'm adding a small amount of flash both before and after it. thanks.....
loopI = setInterval(loopF,40);
to start the waving and use:
clearInterval(loopI);
to stop the waving.
function loopF(){
// move the matrix by speed along x to shift the noise
shift.translate(speed, 0);
// drawing in the perlin movie clip,
// create a rectangle with the perlin noise
// drawn in it with an offset supplied by the
// shift matrix
with (displace_mc.perlin){
clear();
beginBitmapFill(noiseBitmap, shift);
moveTo(0,0);
lineTo(ramp._width, 0);
lineTo(ramp._width, ramp._height);
lineTo(0, ramp._height);
lineTo(0, 0);
endFill();
// draw the displacement movie clip in the
// displaceBitmap (used in displaceFilter)
displaceBitmap.draw(displace_mc);
// apply displaceFilter to the flag
flag_mc.filters = [displaceFilter];
updateAfterEvent();
http://www.senocular.com/flash/source.php?id=0.188i told you and it's in your message:
use:
loopI = setInterval(loopF,40);
to start the waving.
use:
clearInterval(loopI);
to stop the waving.
// do not edit the below code:
function loopF(){
// move the matrix by speed along x to shift the noise
shift.translate(speed, 0);
// drawing in the perlin movie clip,
// create a rectangle with the perlin noise
// drawn in it with an offset supplied by the
// shift matrix
with (displace_mc.perlin){
clear();
beginBitmapFill(noiseBitmap, shift);
moveTo(0,0);
lineTo(ramp._width, 0);
lineTo(ramp._width, ramp._height);
lineTo(0, ramp._height);
lineTo(0, 0);
endFill();
// draw the displacement movie clip in the
// displaceBitmap (used in displaceFilter)
displaceBitmap.draw(displace_mc);
// apply displaceFilter to the flag
flag_mc.filters = [displaceFilter];
updateAfterEvent();
http://www.senocular.com/flash/source.php?id=0.188 -
How to start and stop an embedded sound
I'm putting a sound of a cat purring in the intro to my animation. I've been asked to make it possible for viewers to turn the sound on and off with buttons. I can do it with an outside sound file by using URLRequest.
Is there a way to start and stop the sound if it is embedded in my library? If so, can someone give me that script.
TIAHello mnemo,
You can use your digital signal to stop your generation with the following property node
DAQmx-Triggering
Regards.
Jean-Baptiste C.
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
>> Téléchargez dès maintenant toutes les présentations techniques ! -
How to start and stop server?
This is a design issue that may not belong in this forum, but bear with me, please.
I have a stand-alone RMI server that I start thusly:
public class StartServer {
public static void main( String[] args )
AppContext context = Server.getContext();
String name = context.getProperty("dbServerRegistryName", String.class );
String policyFile = context.getProperty("securityPolicy", String.class );
System.setProperty("java.security.policy", policyFile );
if( System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
Registry registry = null;
try {
ServerImpl server = context.getObject( ServerImpl.class );
server.initialize();
registry = LocateRegistry.getRegistry();
* Use a stub when the server doesn't extend UnicastRemoteObject.
Server stub =
(Server)UnicastRemoteObject.exportObject( server, 0);
registry.rebind( name, stub );
stdout.println("Server is ready.");
} catch( Throwable ex ) {
}The server continues to run in the main thread when main() ends, which is okay I suppose.
Now I have another class that stops it:
public final class StopServer {
public static void main( String[] args )
/* Same setup code */
try {
Server server = (Server)Naming.lookup( name );
if( server.pollReady() ) {
* Remote method requiring admin login to execute.
* Tells the server to quit.
if( server.stop( uName, pwd, delay ) ) {
// unbind?
} catch( Throwable ex ) {
System.exit( result );
} // main()
}The crux of the question is, how should I quit once inside the running server?
public final synchronized boolean stop ( final String uName, final String pwd, final long millis )
throws RemoteException, InterruptedException {
// TODO login
Thread.currentThread().wait( millis );
Thread.currentThread().interrupt();
}The server is single-threaded in that it runs the calling thread to completion - there are no spawned or worker threads.
Does this approach seem reasonable or is there a better technique?The server continues to run in the main thread when main() ends, which is okay I suppose. That's what it's meant to do.
public final synchronized boolean stop ( final String uName, final String pwd, final long millis )
throws RemoteException, InterruptedException {
// TODO login
Thread.currentThread().wait( millis );
Thread.currentThread().interrupt();
}Does this approach seem reasonable or is there a better technique?That won't stop the server, so no it's not reasonable.
You should call UnicastRemoteObject.unexportObject(this, true). You don't need the 'millis' argument to this method. -
Start and stop Weblogic Server 5.1 on unix system
Hello,
How do I stop Weblogic Server 5.1 after I run startWebLogic.sh without
Weblogic Console? What's the best way to start weblogic Server in unix?
Create a user "weblogic" and start manually everytime I reboot the system or
build a script?
Thanks,
Hiu SingHiu Sing Ngai wrote:
Hello,
How do I stop Weblogic Server 5.1 after I run startWebLogic.sh without
Weblogic Console?java weblogic.Admin <url> SHUTDOWN system password <seconds> <lockMessage>
What's the best way to start weblogic Server in unix?I would suggest you start the WLS from command line using our
build script or your own customized scripts.
--Kumar
>
Create a user "weblogic" and start manually everytime I reboot the system or
build a script?
Thanks,
Hiu Sing -
How to start and stop video acquisitio​n in a state machine
hello,
I'm a neuroscience student and here's what I'm trying to do: 1) trigger a GigE camera (200fps), 2) start video acquisition, 3) trigger a light that will stay on for x miliseconds, 4) trigger a valve that will blow an air puff, 5) stop the tone and the valve simultaneously and 5) stop the video acquisition 1second after 4). For that, my VI is a state machine, with a state for each trigger (ex, 1 state for trigger camera, 1 state for trigger light, ect) plus a state to "stop" and a state "time to wait". Everything was working except the video acquisition - the program would trigger the camera but only acquire one frame, because it wasn't running in a while loop and this is my first question: for a video acquisition is it always necessary to have a while loop?
I assumed the answer was yes, so I built a "consumer" loop for the camera. Putting a queue in the state "trigger camera" in the producer loop, I was then able to start the video acquisition but now the problem is to stop it in the right time. I have another queue in the "stop" state in the producer loop, but it isn't able to start the "stop" state in the consumer loop, I think that may be because the consumer loop gets "stuck" in the while loop.
I hope you can help me, the VI is attached. Thanks!
Solved!
Go to Solution.
Attachments:
trigger_cam.jpg 345 KB
trigger_stop.jpg 354 KB
Conditioning MS vi 2010.zip 68 KBHi Gak,
Thanks for the suggestions. I still didn't got it to work though. I moved the stop command to inside the while loop like you said but it didn't work. The problem seems to be in the communication between the producer/consumer loops. When I run the VI in highlight, the queue message "trigger camera" leaves the producer and arrives at the consumer loop in the appropriate time, starting the "trigger camera" state of the case structure. However, the message "stop" doesn't seem to be sent by the producer loop, so the consumer doesn't receive a signal to start the "stop" state of the case structure. Can you think of anything I should change in the producer loop so that the second state (stop) is added to the queue?
About the functional global, I read about it, it seems that either that or a local variable could work, but I don't quite know how to implement it in my state machine, since the stop of the first while loop isn't activated in the "stop" state but in the "shutdown" state. It works more or less like this: after 10 loops of triggering and stopping the camera, light and valve (so after acquiring 10 movies), it goes for shutdown. Can you show me what you had in mind with the functional variable?
Attachments:
Untitled.jpg 286 KB
Maybe you are looking for
-
How to assign two url for a single picture?
I have a picture and put it into sprite,like follows: var loader:Loader=new Loader(); addChild(loader); loader.load(new URLRequest("logo.jpg")); At the right top of logo.jpg,and there are two word location in the logo.jpg,one is 'home' and
-
i have had itunes downloaded on my computer before but the computer had to be repaired becuase it had viruses and now i cant reinstall itunes. whenever i try to install it again something pops up that says a fatal error has occured or something like
-
Ipad 3 64 gb. Notes application opens but won't do anything. I can't write a new note or anything.
-
Hi all, i have a report which has to display country wise sales based on the prompt(having drop down values: India, Australia, SouthAfrica). Here i have set filter for the country (Is prompted) in the report. On the selection of the prompt value, the
-
Pixelation issue resizing jpeg Logo - Illustrator CS5
I'm working on a file where they've supplied me with their logo only in jpeg format. I'm trying to lower the size for the small artboard (to approx 15% of it's original size) but can't find any way to make it even the slightest bit smaller without no