WSO2 Application Server wont start via jenkins post steps shell script - shell

I am using jenkins CI to build my project. After the build I had post steps shell script copy the war to WSO2 application servers /repository/deployment/server/webapps/ folder. But what I observed was sometimes ( not always ), the server failed to redeploy the web application. Most of the times the web application would be redeployed using the new war file copied by jenkins into the webapps folder. But sometimes this did not happen. At such times the only solution was to stop the wso2as server, delete the web applications folder leaving only the new war file in wenapps directory and start the wso2as server again. This deployed the new war file and testing could proceed.
But we need to run automated selenium tests. So for the tests to run we need the new war file to be deployed reliably on every jenkins build.
So I wrote a little script in the jenkins post step like below :
#!/bin/bash
/home/kk/wso2as-5.0.1/bin/wso2server.sh stop &&
sleep 1m &&
rm -rf /home/kk/wso2as-5.0.1/repository/deployment/server/webapps/Duster_App1* &&
cp /home/kk/.jenkins/workspace/Dusters_App1/target/Duster_App1-${MAVEN_VERSION}.war /home/kk/wso2as-5.0.1/repository/deployment/server/webapps/Duster_App1.war &&
/home/kk/wso2as-5.0.1/bin/wso2server.sh start &&
echo Starting wso2as
This script runs. The wso2as server is stopped, the webapp folder is deleted, the new war file is copied corectly in place, I get the 'Starting wso2as' message on jenkins console output, BUT the wso2as server does not start. It remains in the stopped state. I introduced the sleep 1m line after the wso2server.sh stop command thinking the server may be taking time to shut down and hence fails to start again by the time the wso2server.sh start command is run. But no. The server is stopped cleanly before the start command is run as I have verified by following the log file as well as by ps aux command.
So what could be preventing the server from starting again?

IMO writing a script to delete webapp folder and restart the server from time to time would not be a good idea. I would suggest you to do following steps and then try the deployment from your jenkins build server to AppServer repository/deployment/server/webapps.
1.) Stop the server
2.) Open the [AS_HOME]/repository/conf/tomcat/catalina-server.xml config file
3.) Now make the unpackWARs attribute in Host element "false"
4.) restart the server
By default AppServer would extract the WAR file inside webapps, and it is possible that this could cause intermittent issues when deploying the same webapp again and again. Please try this way and see.

The WSO2 servers are OSGI based. The modules offer also web services for all tasks you can do in the admin console. If you start the server as ./wso2server.sh -DosgiConsole and you can list all service interaces with osgi> listAdminServices. You will find i.e. interfaces to upload WAR, CAR and AAR archives. The upload is one stateless call, but the handling of the artifact upload is a little bit tricky and you have also to deal with the self signed certificates of the WSO2 server. You can do the upload in a script language of your choice or make a simple Jenkins plugin and integrate this into your build job.
If you want comfort and don't do it yourself, use this Jenkins post-build plug-in to deploy the WAR into the WSO2 AS via the deployment web service API: https://github.com/ma-ha/Jenkins-WSO2AS-Deployer

Related

How to upload and run jmeter script from server

There is a need to upload the script from local to server and then run over there. can someone please let me know how to can achieve this.
Just copy it from local machine to the "server" using SCP for Linux or SMB for Windows, once done you can log into the server over SSH or RDP and execute your JMeter test in command-line non-GUI mode
If you want fully unattended/automated execution consider the following:
Setting up a version control system, i.e. use Github to store your script(s)
Configure the Webhook to trigger an action when you commit the file
Install Jenkins on the server
Configure Jenkins to listen to the Github Webhook and when it happens kick off a build running a JMeter test
This way whenever you add new or update existing script it will automatically trigger the job which will execute the test, check out How to Integrate Your GitHub Repository to Your Jenkins Project article for detailed steps if needed.

Deploy hippo cms in heroku

In Hippo, There are two web applications packaged as war files inside a directory called webapps, a number of libraries in a directory called shared/lib, another set in a directory called common/lib, and some configuration files such as a log4j descriptor and a Tomcat context descriptor in the conf directory.
But in Heroku, I can not find the directory of tomcat to deploy these directory like the structure of Hippo (shared/lib, common/lib, conf)
Thank you
Hippo requires access to the entire Tomcat instance for setup at least. I've read through the Heroku documentation (most of it just skimmed), but I can't see that they provide that access.
However, there is possibly a second option which you may be willing to try; build Hippo in a docker image, and deploy that into Heroku:
Creating a docker container for hippo
Deploying docker container to Heroku
I haven't tried or tested any of this, so I can't guarantee it's success. But if you're limited to using Heroku, then it's at least worth a try.
Also, if you manage to get it running using docker, I would be extremely interested to know more details.

Deploying an osgi bundle (jsp hook) in liferay 7

Created an osgi bundle (jsp hook) in liferay. Using the server tab in Liferay Workspace environment, added the bundle to configured server.
Checked the osgi shell with
lb -s mytest.hook
START LEVEL 20
ID|State |Level|Symbolic name
455|Installed | 1|mystest.hook (1.0.0.201603221133)
The state is "Installed". Not sure how to proceed further in terms of the deployment. How will the State change to "Active" ?
Try the following command:
start 455
Probably your bundle does not resolve correctly. You should get a an exception that tells you the reason after calling start.
I was able to get it deployed successfully by actually putting it to the deploy folder, from which the Liferay's deployer kick's in and does the rest. So basically the deployer doesn't get notified when you do it from the server tab and add you project for deployment.

Play! Framework app on EC2

I want to deploy and run my Play! Framework app on EC2.
I have installed the Play! Framework on one instance, now I don't want to copy my source code over but instead I want to "build" my app into libraries/jar/wars and copy the binary over and have play run against the binaries. Does Play! support that?
You can deploy your play application as standalone java application without installing play framework on EC2. You will need to generate distribution file of your play application by following step
Navigate to project folder
type play
type dist
This will generate project snapshot zip file in dist folder of your play application.
Upload that zip file to EC2 instance and extract in some folder. There you will find a start shell script file. Just execute that script file
Note: To make file executable type: chmod 777 start
./start
This will publish application and opens port to receive http request on default port 9000. If you want to change port when executing file,
./start -Dhttp.port=8080
This will publish application on port 8080
No, there is no native single-file format for play apps.
But, yes you can use any archive format for your purpose. Instead of running :
play command myfile
you'll do something like this :
unzip myfile; play command file;
Plus, you could always try using wars and rune those across multiple tomcats, but it would be a waste of ressources as native play server is better.
Well, the Play documentation mention it clearly that you can.
play war myapp -o myapp.war
Take a look on Play documentation, its very clear.
If you are using activator you can exploit its stage command which prepares all dependent libraries and compiles your code.
In my blog, I have tried to explain the whole deployment scenario of an Play application to an EC2 instance. Here is the link for more detail:
http://www.javacirecep.com/cloud/deploy-play-scala-applications-on-amazon-ec2/

Changing the user executing the build script in Atlassian Bamboo

Here is my problem:
I have a python build script building a .air package and deploying it on a server. If I run this script from a cmd.exe window, there is no problem, the files are correctly created and deployed.
But I would like to use Bamboo to be able to build my app everytime I commit/push changes. I configured it but have a serious problem: the .air package is created but the deployment (with a fabric script) doesn't finish... I noticed that the process is launched by 'Administrator' in a cmd.exe and by SYSTEM trough Bamboo. I think that this is the problem (maybe SYSTEM cannot find the ssh host or whatever), so I wanted to know if someone knows how to change the user executing the script to 'Administrator'.
Yes, you can change the user that your bamboo server runs as. I recently posted an answer with details on how do just that in Windows Mercurial global keychain . All the documentation for the windows stuff in the wrapper file can found at http://wrapper.tanukisoftware.com/doc/english/props-nt.html .

Resources