Unable to keep Selenium Server Running after Putty Close - java

First, install the Selenium Server:
Download a distribution archive of Selenium Server.
Unzip the distribution archive and copy selenium-server-standalone-2.9.0.jar (check the version suffix) to /usr/local/bin, for instance.
Start the Selenium Server server by running java -jar /usr/local/bin/selenium-server-standalone-2.9.0.jar.
I can let it run but when i close my putty, the server shuts down. Is it suppose to be that way? As in, does the code initialize the server when they need? or how do I find a way to keep it running?.

This is normal, when you close putty all your commands will be killed.
To keep your commands running, you need either to :
Create a script that will launch this command
run your command using : nohup java -jar /usr/local/bin/selenium-server-standalone-2.9.0.jar &

Related

Listen to serial port at STARTUP using java with arguments on Debian(Rasbian)

I've been stuck two weeks trying to figure out how to run this at startup.
I use the following chain of commands on the terminal:
1. source ~/.bashrc
2. source ~/.tinyos.sh
3. java net.tinyos.tools.Listen -comm serial#/dev/ttyUSB0:telosb | python demo.py`
The third command uses java to listen to the serial port and pipes it to a python script which cleans, converts and uploads to mysql localhost.
This works fine on ssh terminal. But ive tried using nohup+update-rc.d, upstart, systemd, crontab to make it run on startup and it just wont work! When I reboot and check logs / database, its as if the command never happened. I need this to run like a daemon and continue running until shutdown.
Thanks a lot.
How are you trying to execute the program ? Are there are permission issues accessing / executing the script ?
Which version of debian are you running - look at upstart scripts if you are running Jesse+
I'd put those three lines in a bash script and use upstart scripts to trigger them on start. Another option is to use supervisord to make sure that your scripts run and restart if for any reason the program crashes.

Starting selenium server from java in the background

I want to make easy-to-use selenium tests - just run one file and it starts the server, connects to it, run the tests, then close the server and exit (on windows).
I don't want the user to see the selenium console so I want to hide it if possible (run it in background and maybe log output). How can I start selenium server directly from Java?
Well, it wasn't that hard (at least on windows). I used to start selenium server like this:
java -jar selenium-server-xxx.jar <options>
To start it without console I just use javaw:
javaw -jar selenium-server-xxx.jar <options>
Create a windows .bat file and run the .bat file to start the selenium server. You can also include your test classes and dependencies.
eg:
java -cp ".;.\supportlibraries\junit4.11.jar;.\supportlibraries\poi-3.8-20120326.jar;D:\downloads\Selenium 2.0\selenium-server-standalone-2.45.0.jar" org.junit.runner.JUnitCore [classname]

How to run Solr 5.0 as a background process in Windows?

How would one run the "bin/solr.cmd start" script so that it runs in the background in windows? Formerly, you could either run on tomcat and effectively run as a windows service. Alternatively, you could run the start.jar directly with "nohup" to prevent the hangup when the command prompt is closed.
With the release of Solr 5.0, it appears that Solr is now a standalone Java application that must be started with the start script (not a direct jar file).
Currently, if the command prompt that initiated the start command on Windows is closed, the application stops.
You can use Apache common deamon library or sc.exe (Windows Library) to "install" something as a service, which it sounds like you want.
I had the same problem upgrading from solr4
Solr 5 runs as a background service as default. Adding the -f parameter would run it in the foreground (which is needed if you run it as a windows service).
I'm using nssm (https://www.nssm.cc/download) to install Solr 5 as a windows service:
C:\nssm\nssm64.exe install "Solr 5.3.1" C:\search\solr-5.3.1\bin\solr.cmd "start -f -p 8983"

How do I run a Java .jar file as a Windows service on Windows Server 2008?

How do I run a Java .jar file as a Windows service on a Windows 2008 server? I have a jar file called SomeJavaFile.jar located under the C:\SomeDirectory directory on a Windows Server 2008 box. I usually just run this jar manually in the command line with: java –cp SomeJavaFile.jar com.ctg.SomeJavaFile and I let it run 24/7.
The problem with our Windows Server is if it restarts I need to run it as a service so it will automatically start as a service upon startup, because our processing for Vistakon runs 24/7. I have Googled around and tried to use a service wrapper and the sc.exe command to create the service.
I put the wrapper service.exe in the C:\SomeDirectory\. I use the following command to create it: sc.exe SomeJavaService binPath= “C:\SomeDirectory\service.exe \”java –jar C:\SomeDirectory\SomeJavaFile.jar\”” type= own start= auto error= ignore. This creates the SomeJavaService service correctly but when I try to start it I get an error that says the service on Local Computer started then stopped.
Some services stop automatically if they are not in use by other services or programs. Do I need to alter my sc.exe command to have the exact previous working command line maybe, by adding in the com.ctg.SomeJavaFile? So should I change This jar should just run in the background and constantly poll/ping the C:/poll directory then if there is data present it processes the data and sends an export file to another directory.
I have used this same .jar file for years successfully and it hasn't changed, but I cannot get it to run as a Windows service. This is the site I use to get the service wrapper http://code.google.com/p/simple-service-wrapper/. Any help would be greatly appreciated!
"winsw" is the standalone version of the Windows Service installer shipping with the Glassfish Java EE reference implementation.
Works well, but is not a fully polished product - I have used it for exactly this purpose for a couple of years. Requires .NET in some recent version on the Windows machine.
https://github.com/kohsuke/winsw
I think that the best bet would be wrap your java app with Procrun of Apache Commons Daemon .
Procrun is a set of applications that allow Windows users to wrap
(mostly) Java applications (e.g. Tomcat) as a Windows service.
The service can be set to automatically start when the machine boots
and will continue to run with no user logged onto the machine.
As per my analysis,
The Idle Solution will be writing a VC++ (.net) Windows Service creation program to launch the .bat (that triggers the jar file)/.exe as a System service with all the required call back methods to SCM.
Note : 1. Wrapping the process with sc.exe / srvany.exe would not work as it does not have any call back process to the SCM (Service Control Manager). 2. And java service Wrapper is a third party API (many are LGPL licensed).
If you start your Java code from commandline by using java -j some.jar does it run until you terminate the program, or does it stop by itself?
There needs to be a NON-Deamon Thread, that is running all the time. A JVM will terminate, if there is no thread running, that is not flagged as daemon.
If you have a little budget, buy an installer tool. I use instll4j. With that tool, you can create service launcher and install them during instllation.
The following solution is working fine for me having OpenFire Connection Manager (which is a jar file) running as service on Windows Server.
Download and install the Non-Sucking Service Manager
I didn't use the batch made by OpenFire team, because it didn't work for me (dependencies not found error...) So, make a batch file with the following code :
#ECHO OFF
cd /D "E:\connection_manager\lib"
java -jar startup.jar
and save it as cm_startup.bat in the bin folder of connection manager.
After that you can create the service with NSSM.
So, open a cmd.exe and run the following command :
nssm install ConnManager "E:\connection_manager\lib\cm_startup.bat"
.
Doc & examples
More documentation and examples for the Non-Sucking Service Manager here : https://nssm.cc/usage Actually NSSM as a lot of options available.
Here is a more complexe example :
nssm install solr "%JavaExe%" -Dsolr.solr.home="\"%CD%\solr"\"
-Djetty.home="\"%CD%"\" -Djetty.logs="\"%CD%\logs"\" -cp
"\"%CD%\lib\*.jar"\";"\"%CD%\start.jar"\" -jar "\"%CD%\start.jar"\"

Running Java application on server

I have access to a server using SSH. I need to run a stand-alone Java application on it to access a MySQL server installed there. How do I go about in doing this?
Assuming you have the requirement to copy the JAR file on the *nix box and then run it(and not connect a Java process to it remotely)
Create a standalone JAR which contains all the dependencies required to run the application
Make sure you have Java installed on that machine
Assuming it's a *nix box, set the $PATH environment variable to point to $JAVA_HOME/bin
Log on to that box using a SSH client. Any decent SSH client also comes with a FTP plugin which allows you to transfer files between your local box and the server
Copy the JAR to the appropriate directory and run it using the java -jar your.jar command
Assuming it is a linux machine, you have to connect to by using SSH it and use scp command to upload the files and deploy it...
than you have to run the JAR you deployed:
java -jar /path/to/file.jar
Or, provide more details please

Categories