I'm trying to run a function that we have to recycle our tomcat instance when doing a deploy to tomcat via bamboo. I thought that we would be able to use bamboo's ssh task to call our function tomcat recycle. I am able to run the function ssh connected to the box via putty but in bamboo we get the message:
ksh: tomcat: not found
Does anybody have any experience restarting tomcat automatically via bamboo? Is there a better way?
To restart tomcat via Bamboo
Create a ssh task -
You should be having tomcat service file in /etc/init.d (if you are using redhat)
/etc/init.d/tomcat start
/etc/init.d/tomcat stop
/etc/init.d/tomcat restart
should work
Related
I have implemented a dashboard servlet for my linux server. I wanted to add an option for "restart main services" to this dashboard. Basically the dashboard just run bash script with the ProcessBuilder object from java.
My main services are just tomcat and postgresql. When I want to restart postgresql, I have to restart tomcat too because if I don't, the existing connection to the database are aborted and even if I restart postgresql, tomcat cannot access my database anymore.
So there is the simple script I use to stop services :
main_services_restart.sh :
#!/bin/bash
sudo service tomcat stop
sudo service postgresql stop
sudo service postgresql start
sudo service tomcat start
If I run it manually, all is going well. But because I run it from my tomcat dashboard, when it calls the script, the script will stop the tomcat service so the script itself is stopped too and so tomcat isn't restarted.
I tried to create differents scripts to detach the main script like this :
sudo -b nohup /home/me/scripts/main_services_restart.sh
or even :
sudo /home/me/scripts/main_services_restart.sh & disown
But this isn't detaching the script from tomcat. How can I completely detach the script from the ProcessBuilder of tomcat ?
I installed multiple instances of Tomcat in my Ubuntu machine. I was trying to start Tomcat (one of the instances from multiple Tomcat instances) from Jenkins. Jenkins is showing that Tomcat started. But Tomcat is still in shutdown state only.
In jenkins, When an build completes all the process Id's which are involved in the build are getting killed.
So mentioning BUILD_ID=dontKillMe ./home/tomcat/startup.sh in Execute shell script make it possible.
I installed the Apache Tomcat/7.0.65 on my Mac, then, run the startup.sh. It works great fine and the service is available immediately. But when I run the shutdown.sh to stop the service. It seems that the shell scripts can not aware of the tomcat running. Would someone please help me with this problem?
I had a similar problem. In my case, although running <Tomcat Root>/bin>./shutdown.sh was technically working (the tomcat process was being killed), the tomcat service was restarting automatically (after a few seconds).
If you run <Tomcat Root>/bin/catalina.sh stop or <Tomcat Root>/bin/shutdown.sh and you see that after a few seconds tomcat restarts => that basically means that you are not able to shutdown tomcat for good. Thus, if you want to make sure that tomcat does not restart automatically, run brew services stop tomcat.
OBS: If you want to find what is your <Tomcat Root> run brew ls tomcat
I have a windows installation of Jenkins, and I run it as regular logged in user on the desktop via java -jar jenkins.war.
Restarting it remotely via the web interface (going to http://jenkins/safeRestart) gives me the following exception:
javax.servlet.ServletException: hudson.lifecycle.RestartNotSupportedException: Default Windows lifecycle does not support restart.
Is it possible to allow remote restart even when not running as a service?
at the moment jenkins build my project and at the end the artifact is deployed on a remote tomcat via jenkins deploy plugin.
the problem is that after several redeployments this process fails (sometimes tomcat hangs or (un)deployment fails). in all cases stopping tomcat and manually undeploying helps.
Is there a way to stop tomcat before building/deploying, delete the old war and appfolder, and restart tomcat before deploy plugin wants to deploy the artifact?
thx in advance
You could write a batch file that does all the things mentioned:
stop tomcat
delete war files
start tomcat again
Then you can add a new pre/post build task in job configuration as execute batch and simply point it to run your batch file.
Added:
You can use PsExec - http://technet.microsoft.com/en-us/sysinternals/bb897553 It allows you to run processes remotely. Put batch on remote machine and from local one using Jenkins run sth like this: PsExec.exe \xx.xx.x.x C:\MyScript.bat
one addition to accepted answer:
it is important to reroute the output and error output of PsExec call (took me 2 days of debugging). See http://jenkins.361315.n4.nabble.com/remotely-executing-commands-td3476417.html
it seems that if called from java (like jenkins/tomcat) or .net PsExec hangs or quits with error. so the call should look like:
c:\someBatchWithPsExec.bat >>log.txt>&1
or explicitly on every call:
PsExec.exe -u [domain\remoteuser] -p [password] /accepteula \remoteMachine net [stop|start] Tomcat7 >>log.txt>&1
i guess if jenkins runs with domain\user u don't have to mention it in command?! (just tried it but it didn't work - the net commands fail)