Is it possible to have ANT restart your java application on a remote server from a build script? If so any pointers to where that might be defined?
I'm using ant now to push the new code over to the remote server but I still have to login to actually restart the app
Using the <sshexec> task you can do pretty much anything on a remote machine (assuming it's got an sshd running). If you don't want to worry about authenticating the ssh session every time, you can set up RSA keys.
<sshexec host="remotehost" username="remoteuser" command="/restart/application/command"/>
Heed the statement at the beginning of the above link:
This task depends on external libraries
You'll need to grab JCraft's JSch jar and put it on Ant's classpath.
Related
Within my organization, I'm tasked with doing some Spark development and I'm trying to use Scala, but much of the other code is Java. I'm managing dependencies with Maven. My code ultimately will work and run on an edge node of a Hadoop cluster (Cloudera).
This edge node is only accessible via SSH through a jumpserver, and I'm struggling to find an efficient workflow. The others on this team have been debugging via including print statements, building .jars locally, copying them to the edge node via WinSCP, and then running them via command line on a Putty session (SSHed into jumpserver, then using SSH command in that session to connect to edge node).
me -> jumpserver -> edge node
I am wondering what a solution would be such that a jar can quickly be built and put on this server and have it run in that environment while being connected for remote debugging.
Eclipse and IntelliJ both have facilities for remote debugging, but can this be made to work through a jumpserver, and when we can only do it through SSH?
Would it work to somehow map a directory on the edge node to my local filesystem and have the IDE put the .jar there and debug it there?
--- Keeping in mind that the .jar would really need to be in the edge node's server context/environment (for Spark/Hadoop hdfs), so this wouldn't work if the .jar would try to use my local Windows environment
What solutions are there to this? Thanks!
Optional other info:
We have Jenkins running to where code automatically built each time we check in code changes, and we have a build/deployment management service in-house that can be configured to actually output a .jar and optionally deploy it to a server. This, however, is much too slow to be practical for running code to check changes and doesn't solve the debugging issue.
Can you check jsch java library by which you can connect to unix server and pass your required command. In your case you need to connect to jumphost and then pass commands like your edge node host and required commands.
Hi I have been doing some manual tasks which consume some of my time and I want to automate it the tasks are:
Connecting to remote windows server using mstsc command and restarting some services.
Connecting to remote windows server and modifying the files, checking the modifications and then again reverting the changes when the changes are tested.
I want to know whether I can achieve a one click solution for this scenario by writing some code in java and reducing the manual time.
Or is there any other solution for the same which can be generic and could be implemented on other servers too.
The steps for the solution to cover would be:
Connect to remote machine using username and password.
Restarting the services from the code or just executing a batch file for the same which could be lying in some folder on the same machine.
Modifying some files on the remote machine.
My friend and me want to explore an Open Source ERP System. We have installed it on a server and we access it by an IP address over Firefox. We're also accessing it over the tools putty (for doing changes like restarting tomcat) , Filezilla (for import export of data), pgAdmin (for accessing the psql db). Now we want to establish a java Eclipse developer environment on both our windows pcs working simultaneously. I need to access, change and commit to the source placed on the server. Every time I commit, I need to deploy the source code with putty.
1) Is there a better way of this way of remote programming? If yes, could you tell me a better way?
2) If not, how can I set this kind of environment in Eclipse (Create an existing project?)
You need configure Jenkins Which will deploy the latest code into remote server
You can use Ansible to automate your deploy
I have an application running on a server which is doing stuff and writing everything it does to a log file.
I also have secondary application which is kind of like a monitoring panel also running on the server but is a different process. What I would like to do is the following:
I would like my monitoring file to be able to copy the log file which currently has a lock on it from the other application and then email it to me.
I have tried using scp to connect to the server and copy it manually to my computer(and it did work), however I would like to be able to do that through my java monitoring application. And I have no idea where to start.
I have tried using scp to connect to the server and copy it manually to my computer(and it did work)
The JSch library has a ScpFrom module that you can use to scp copy the data from the server to your computer or application. This can be done by one of the following:
Manually running the module (eg java -jar)
Copying the source of the module into your project and adding the JSch library to classpath (more programmatic control - preferred approach)
Using the library module programmatically eg String[] args = {user#remotehost:file1" "localfile"}; SCPFrom.main(args);
I faced problem to copy(duplicate) a file from one SFTP folder to another one on the same server.
So, question: Is there a some effective method to do it remotely (i.e. without copying a data to client and vice-versa)?
I am using Java with the JSch library.
The SFTP protocol itself does only support data transfer between client and server, not on the server itself.
You can use other parts of the underlying SSH protocol (and JSch's implementation therof) to execute a command on the server, though. In this case, as mentioned by Joop, an Exec channel is the right thing to use. You can use the same Session you have used for your ChannelSftp also for any number of other channels, e.g. for your exec channel. Just make sure to close any channels after use. (Have a look at the Shell, Exec or Subsystem Channel page at the JSch wiki for some more info.
This will of course not work if the server doesn't support command execution, e.g. if it is configured to only support SFTP. Then your only solution is to download and re-upload this file.
In SFTP one possibly can execute ! ... which is execute local command.
! cp a.txt a-backup.txt
As JSch also can give an SSH connection, even the exclamation sign is moot.
For code you might find some starting point in the examples. The Exec sample should do.