I m doing a eclipse plugin project to create an IDE for a particular language.
For running i connect to the server and ask the user the command,type of connection...
After the program has started execution The only way to stop the execution of the program is by pressing "ctrl+C" when done in the command prompt.
I run the program by sending the server the following command:
"probevue filename.e >output.txt"
when i give this command it is running,but i m not able to stop the program...
i.e when i press Ctrl+C the program should stop execution.
How shall i do this?
Thanks in Advance.
after reading into this article about probevue it seems that you have started a dynamic session. i think the program you're calling is never terminating itself.
http://pic.dhe.ibm.com/infocenter/aix/v7r1/index.jsp?topic=%2Fcom.ibm.aix.cmds%2Fdoc%2Faixcmds4%2Fprobevue.htm
you should first read how to invoke a command properly. e.g. -> http://www.javalobby.org/java/forums/t53333.html
then you should think about how would you terminate the command if you wouldn't have the ctrl+c option, like finding out the process-id of the shell command you executed before (e.g.: ps -ef | grep ) and terminating it by using another shell command (e.g.: kill -9 )
hope this helps you find a solution.
Common eclipse server plugins like JBoss Tools call the server scripts that are delivered with the server for starting and stopping. Deployment/undeployment and starting/stopping of applications is done via the management port.
So either you have a manageable server to control your program, or you could work around the problem by writing the scripts yourself.
Related
I have a java executable that runs a service. It allows the admin to input commands while the service is running. It usually requires an open terminal to run. I connect to my server via ssh.
I can launch the service and it works but I can't exit the terminal without the service closing.
I also can't create a simple daemon because then I won't have access to give the service server-side input.
Is there any sort of daemon where I can have a terminal interface for input, or is there a persistent ssh terminal where even when I exit it will be left running?
to make your process do not close when you exit the terminal you can use command like:
nohup <command/run> >/path/to/log 2>/path/to/errlog &
If you want persistent terminal you can use command like screen or tmux
I have an application which is deployed on Linux environment and has two JVM's simultaneously running. One is producer and one is consumer.
I have different targets written in my ant script for stopping and starting the two JVMs.
There are times while restarting the producer or the consumer, one of the JVMs fail to stop so we have to go and manually find the process id for that particular port and kill that process and then start the application.
How could I automate this and write one script for everything. This script should be able to call the ant targets for stopping the JVMs, kill the process if any JVMs does not stop and finally start the two JVMs.
The first and the last is fine. But how to write things like finding the process id against the port and then doing kill -9.
I am a Java developer so don't know much about this.
If your JVMs are communicating on a socket then try something like
lsof | grep ":$port " | awk '{print $2}'
where $port is the port number. This searches the list of open file descriptors for any matching the required port number and spits out the process id.
I use Amazon EC2 instances to perform some complex computation by using the AWS Java SDK, these computations might take so long sometimes. Hence, I need to kill the process running on the EC2 instance remotely from my Java code so that I can reuse the same instance for another task without needing to stop and start the instance.
The problem with stop and start, is that Amazon treat partial hours as complete hours, so my aim is to make my code more cost effective.
I use SSH to connect with my EC2 instances and that is how I pass commands to be executed there. I doubt that if I disconnect the SSH connection and connect to it again, it would kill whatever process was running there.
In short, what I need is away of doing Ctrl+C but from within my Java code (without user intervention). Is that possible?
EDIT:
To clarify, the computation is executed by a separate tool installed on the Linux EC2 instance. So I just pass the command to start this tool, then the command line waits until its finished and shows the results. On manual usage scenario, I can click Ctrl+C on linux command line and will get control of the command line back. But in my case, I want to do similar thing from java code if possible.
Use the SIGAR library to scan the process list on a machine and kill your process.
Use getProcList() to get all process IDs, getProcArgs() to get the full command line of each process, and kill() to kill the relevant process or processes.
So if a task is running and you want to kill it, SSH again into the machine and run your SIGAR based process killer.
One dirty/functional way would be to kill your process via SSH using the java Runtime to execute it.
Something like
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec("ssh user#host command");
So in your case, if you know the program's PID (1234 for example):
Process p = runtime.exec("ssh user#host kill 1234");
Or if you know the program's name:
Process p = runtime.exec("ssh user#host pkill my_program_name_x64");
Note that you usually have to give absolute paths to the executables invoked via runtime.
So you'll have to replace ssh by something like /bin/ssh or /usr/bin/ssh as well as for kill and pkill or killall.
I need to debug a web application for Tomcat6 in IntelliJ IDEA.
When I try to run my web application, I get two errors:
Address localhost:1099 is already in use
Unable to open debugger port: java.net.SocketException
Launching the Apache Tomcat 6 service manually works fine.
What should I do in order to be able to debug web applications in Apache Tomcat 6 from Intellij IDEA?
Following the below steps work:-
Open command prompt and type the command netstat -ano
You will see a list of active TCP connections with PID as the last column
See the second column listing the local addresses and find the one using port 1099 from it and you'll get its PID
Now open your Task Manager, click the Process tab and get the PID column to display [either by right clicking on the heading row and selecting PID OR click View, and then click Select Columns and select PID.]
Now find the PID we got from Step3 and end the process.
Now you are good to go :)
I face this issue all the time. Here's how to fix it
LINUX
Open a terminal instance.
fuser 1099/tcp
This should return you a process ID.
1099/tcp: 31596
where 31596 is the process ID. Now you can either use the process ID to kill it or just bash the following -
fuser -k 1099/tcp
WINDOWS
Open a command prompt instance.
netstat -aon | find "1099"
This will return you an instance of the process.
output:
TCP 0.0.0.0:1099 0.0.0.0:0 LISTENING 15776
Here 15776 is the process ID. To kill this, enter -
taskkill /F /PID 15776
Cheers!
You can change the JMX port (1099 per default) in the Run/Debug Configuration dialog. Just try a different port number (i.e. 9099).
If you had the web application up and running before, there may be an old debug server that did not close down properly running in the background. See this post about how to find what process that uses port 1099. If it proves to be a java process, kill it.
How can you find out which process is listening on a port on Windows?
(If you use the GUI sw suggested in the link above, you may kill the process(es) by marking all java processes that uses port 1099, right click and press "End Process...")
As said before, there's an old debug server running in the background.
My solution was to close the Java process that was left open from the Windows Task Manager.
Please verify that you can close this process before doing so!
Change your http port to 8080(default for tomcat) and debug port to something that is not being used currently by any processes. You can use anything that is upwards of 1024, but since you are getting an error on 1099, try something that is greater that 6000.
Debugger setting can be found here
There might be other program or server running at the background. First close other server running in the background and then restart your server.
I found this answer helpful:
How can you find out which process is listening on a port on Windows?
I opened the resource monitor and looked for what was using the ports. Then opened task manager and ended those processes
What worked for me was. I assumed I would need to have the "Apache Tomcat" service running under "Services" [Windows + R >> services.msc]
I went and stopped the Tomcat service here. Then I came to my Java application and ran it in Intellij, which allowed me to run it.
Hope this helps!
Just close all other unnecessary servers while using InteliJ.
I stopped my WAMP in order to remove this error "Port is already in use".
I have started the WSO2 ESB server with ./wso2server.sh , but there is no script to stop the server ?
Can anybody tell the command to stop the server ?
Thanks
Suresh
If you have started the server using ./wso2server.sh then you can stop the server by pressing Ctrl and c keys together on the console, it will simply kill the server.
If you have started using ./wso2server.sh --start or ./deamon.sh start then you can kill the server using the commands ./wso2server.sh --stop or ./deamon.sh stop.
./wso2server.sh --stop or ./daemon.sh stop
Generally, pressing CTRL + C in the terminal you started the server would do.
If it's not possible for you, then do the following.
Enter the command ps ax | grep wso2esb
This will list the set of processes started that has the text wso2esb. Unless you opened several esb instances, there will be one process that would like the following [1]. There, the first number refers to the process id.
So, enter following command to gracefully shutdown the esb.
kill <process-id>
You may force the shutdown by sending signal kill (-9) like follows if you need to.
kill -9 <process-id>
As you may have noticed, the kill command is a native program that comes with most linux distros, not a wso2 provided one.
To stop the server,
If you have started the server using ./wso2server.sh then you can stop the server by pressing Ctrl+C in the command window
If you have started using ./wso2server.sh --start then stop using ./wso2server.sh --stop
If you have started using ./deamon.sh start use ./deamon.sh stop
clicking the Shutdown/Restart link in the navigation pane in the Management Console works well for all..
On Management-Console, we can shutdown or Restart
On management console we can shutdown / Restart
This is an old thread... but I since I arrived here with the same question, I may as well post the answer I found for future users.
Another way to shut down the wso2 server is through the online admin console. Once the server is running, simply navigate in your browser to
https://localhost:9443/carbon
Log into the server's admin page using the default username and password, "admin" for both. Then scroll to the bottom of the page and select "shutdown/restart" and select "graceful shutdown" from the menu.