How to start Jetty with multiple standalone instances? - linux

I am trying to start two instances of Jetty in different ports (one is 8080 and the other is 443).
I created two jetty.base directories using start.jar with the parameter --add-to-startd.
When I run "java -jar /opt/jetty/start.jar" in the first app directory it starts normally, port 8080.
When I run "java -jar /opt/jetty/start.jar" in the second app directory, it kills the first process. And after that starts normally, port 443.
If I change the order the same thing happens.
How can I run more than one instance of Jetty without one killing the other?
Jetty: jetty-distribution-9.3.0.M2
Java: jdk1.8.0_25
Operating system: Linux CentOS release 6.6

I found the problem, the process died because the server was out of memory.
I didn't see any Exception in the logs, but monitoring the machine, I saw that when the memory was close to 100% the process died.

Related

Grails run-app fails on VM VirtualBox: hangs on build, can't access server

I'm new to Grails and attempting to implement the Hello World app described at grails.org's Getting Started guide.
I have installed Grails using SDKman on an Ubuntu Server 16.04 VM (VirtualBox, running as a service). My host machine is Windows 10.
I configured two network adapters in VirtualBox: the first a NAT with port forwarding (3022 host -> 22 guest, 8080 host -> 8080 guest), the second a Host-Only adapter.
I can SSH into my VM just fine from my Windows host (using Bash): ssh -p 3022 user#localhost
When I run python3 -m http.server 8080 from that SSH session, it successfully listens on both localhost:8080 and :8080. I can access both URLs from a browser on my host machine.
When I run grails run-app it hangs forever, and none of the above endpoints work from my host.
When I run grails run-app --verbose I see it compile without complaint through "Building 85% > :bootRun". I understand that this is expected behavior, but I never see "Application started" or any similar message. It never starts.
ONE TIME the following command succeeded in building and running the app, creating exactly the result I needed:
grails -Dserver.port=8080 -Dserver.host=0.0.0.0 run-app --verbose --stacktrace
However when I stopped the app and tried again, it failed as before.
I notice that VirtualBox > Settings > Network > Adapter #2 which I had set as "Host-Only Network" has multiple times reset itself to Bridged. I suspect that this reset may have caused my problem. But I don't know how to prevent the reset, or to restore that functionality I so briefly had.
Thanks, anyone who can help!
Resolved! Turns out run-app just takes a LONG time to finish compiling and building, upwards of 10 minutes. So I just needed to wait ~5+ minutes with no visual sign of action before the completion message would show and I could access my site. :)

Determine what script a node process is running

I'm using PM2 on a Windows server to run a bunch of different scripts. I have found that sometimes when I issue a stop with PM2 it reports the process as stopped but the node process is still running.
I want to be able to determine what script is being run by the node process (as reported by Windows task manager). If I was binding to a port I could figure it out with net stat but these scripts don't listen on ports, rather they connect to Rabbit MQ.
If I can identify the task in Windows I can forcefully terminate it using task manager.
I think you're looking for tasklist /FI "Imagename eq node" (or something similar)
Related: https://superuser.com/questions/18830/is-there-a-command-in-windows-like-ps-aux-in-unix
Docs for tasklist: https://technet.microsoft.com/en-us/library/bb491010.aspx
Related, if your process is listening on a port and you know that number: How can you find out which process is listening on a port on Windows?
If you're connected to RabbitMQ your PID will be in the Consumers section of the queue, something like this: node-amqp-37997-0.5310617093928158 where 37997 is the PID of the process listening.

Tomcat Maven Plugin: shutdown when running on non-standard port

I am using a software which comes as a source tarball and maven pom.xml which builds a war and eventually gets run like this:
mvn tomcat:run -Dmaven.tomcat.port=1234
When I run this command in the background, I am unable to subsequently shutdown this server using
mvn tomcat:shutdown -Dmaven.tomcat.port=1234
I have not found a way to define a shutdown port when starting, nor any documentation if the tomcat which is started that way uses any other of the ports that are normally used in the standard Tomcat configuration, especially the shutdown port and shutdown string. It looks as if not, but can anyone confirm this? Does this mean then that the only way to shutdown the server is by explicitly killing the process? But what is the purpose of the tomcat:shutdown then?

How to start a daemon thread as soon as the jetty server starts

I have a requirement on starting daemon thread once the jetty server starts, I have a idea on it,
when you issue mvn jetty:run on the terminal it will compile and run the jetty server.
on the terminal you will see info as :Jetty server started, now is there is a way to find out whether the server started or not. for ex. if the jetty server object name is "server" then by checking server.isStarted() or not will work or not.
How to start a daemon thread(java) once the jetty server starts.
I am trying to start a daemon thread once server.isStarted() is true.

Shutdown Cassandra server and then restart it in windows 7

I installed single node cluster in my local dev box which is running Windows 7 and it was working fine. Due to some reason, I need to restart my desktop and then after that whenever I am doing like this on the command prompt, it always gives me the below exception-
S:\Apache Cassandra\apache-cassandra-1.2.3\bin>cassandra -f
Starting Cassandra Server
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 7199; nested exception is:
java.net.BindException: Address already in use: JVM_Bind
Meaning port being used somewhere. I have made some changes in cassandra.yaml file so I need to shutdown the Cassandra server and then restart it again.
Can anybody help me with this?
Thanks for the help.
in windows7, with apache cassandra, a pid.txt file gets created at the root folder of cassandra. Give following instruction to stop the server:
d:/cassandra/bin> stop-server -p ../pid.txt -f
Running -f starts the server as a service, you can stop it through the task manager.
It sounds like your Cassandra server starts on it's own as a service in the background when your machine boots. You can configure windows startup services. To run cassandra in the foreground on windows simply use:
> cassandra.bat
If your are using Cassandra bundled with DataStax Community Edition and running as a service on startup of your machine then you can execute following commands to start and stop Cassandra server.
Start command prompt with admin rights
run following commands
net start DataStax_Cassandra_Community_Server
net stop DataStax_Cassandra_Community_Server

Resources