How to make Grails development less dependant from Amazon EC2 - grails

Today I was converting a web application that use Grails 1.3 to 2.0 when I notice longer and longer response times trying to compile and run. An hour later, after deleting the local ivy cache and some files related with the IDE, came to the conclusion that the problem was an Amazon EC2 outage affecting several sites including Grails' repositories. Every time I write a simple command as grails compile or even grails help, the framework try to connect to EC2. We have a Nexus repository where we store our projects and dependencies. There is something we can configure in order to avoid this behavior and use the local Nexus instead? Thanks in advance.

Glen Smith wrote a great article about this: http://blogs.bytecode.com.au/glen/2012/06/04/seriously-offline-grails-going-totally-sans-internet-with-nexus.html

Related

Apache Service Mix Deployment Approaches

Folks,
We have got an enterprise application which uses Apache Service Mix for deployment. The application consists of various services and each is created as separate Maven project (bundle).During development, we are actually building each service separately and in-order to deploy it,its being put in the deploy folder. Also, we have to uninstall the bundle from the container(say; karaf) and then install it again from the console to bring the new changes in effect. This is fine during the development phase.
Now we want to deploy the code to an UAT environment (Amazon EC2) for the client to do the testing. We are now confused about how to deploy the bundles to the remote environment. Do we have a standard approach for CI using Jenkins(or some other tool) to automate the build and deploy process , so that someone who has no knowledge about the bundles(SMX) can deploy the code. We are using Github for source code management.
We have searched a lot in this regard and couldn't find any resources which provide some leads/hints on this.
Any help/tips is highly appreciated. If you need more info, I can give more details.
~Ragesh
We do have exactly similar setup and we use the Jenkins to build and let the Sysadmin to copy the bundles to one server and then he enables the rsync to rest of the servers.
Remember, always deploy the dependent bundle first and then remaining ..
Since we have this dependency ,we can't go automating this process.

Firewall blocks access to grails repo

refresh dependencies fails due to firewall+proxy combonation.
The corporate IT is not going to make an exception. I have found that I can do a recursive wget on the repo url and generate duplicate their folder structure.
What can I do locally so that all developers can use this "mirror" by default?
If the above is not possible, where does grail usually put these files on a windows based installation?
Try adding local repo to your BuildConfig and of course make it accessible over your LAN, or perhaps tell other devs to make their local cloned repos. The path to this local repo could be ENVARIONMENT_VARIABLE, too (that makes it fully customizable)
repositories {
grailsPlugins()
grailsHome()
mavenCentral()
mavenRepo('/path/to/my-local-maven-repo')
}
http://jdpgrailsdev.github.io/blog/2014/02/10/grails_maven_local_repo.html
You have a couple of options here.
First, if it's just a normal proxy than you can configure grails to utilise it. Take note of the following grails commands:
grails add-proxy
grails set-proxy
These in turn will establish a file in your home directory in .grails called ProxySettings.groovy (i.e. ~/.grails/ProxySettings) that is then used by all grails commands for all projects.
However, if you're behind a Microsoft NTLM proxy (as I am) then I'd suggest still doing the above by making use of Java NTLM Proxy.
(Keep in mind though, that the grails wrapper does not use the above ProxySettings.groovy and then you need to use the standard JAVA_OPTS of -Dhttp.proxyPort, -Dhttp.proxyHost, etc.)
But I appreciate maybe you've done all that and you still want to avoid the proxy. I'd suggest the next solution - and one that should be considered anyway - is setting up a corporate/internal Maven repository server with something like Artifactory or Nexus.
Lastly, there is the instruction from MamyKryzysKryzysKryzys with using mavenRepo( <localPath> ). More info on that is available in the grails doco.
Finally, to address your question of "where does grail usually put these files". Under the hood grails is simply using maven so it's stored in your normal maven local repo which is ~/.m2/repository.
Good luck! Proxies make things hard, but once you figure your solution it's a thing of the past. Personally, we now use a combination of the Java NTLM Proxy and an internal Artifactory server.

archiva standalone vs web

can some one help me. I want to setup a internal repository for maven. For this i wanted to use Apache Archiva and i'm new to both maven and archiva. My question is what is the exact difference b/w standalone and web archiva installations (i found these 2 ways in archiva documentation).
My intention is to create internal repository to be used by all developers. Every one should get dependencies from there. I have to install archiva in a server with in our organization(LAN). What is the preferable for my situation?
I found steps to install in both ways, but they are little confused as i am new to archiva. Could some one please explain me clearly?
Operating System : Windows
Maven : 3.0.5
Archiva : 1.3.6
Thanks in advance.
The standalone distribution is more easy to install.
The wrapper will restart your instance in case of issues.
The important part is to separate content from installation see http://archiva.apache.org/docs/1.4-M3/adminguide/standalone.html section "Separating the base from the installation"

How to monitor and maintain my grails application in live/production environment?

It is the first time I have ever launched live a website (with Grails web framework under Amazon EC2 platform and Cloud Foundry) and I realized quickly that I am not ready for monitoring and maintening correctly my application in production mode (fortunately the website is accessible to a very limited number of users) .
The issues I have faced so far are:
Cannot change my views. I need to redeploy my application
I have no monitoring. I don't know who is connected, when do they sign in / sign out...
Redploying my application (upload WAR + deploy) takes at least 30 minutes.
I don't know how to restart my Tomcat server without a redeploy through Cloud Foundry !
...
So, my question is very simple:
What tools (including grails plugins) and methods can you recommend me for taking me out from my current blindness?
I am not sure how much this will help, however I use the JavaMelody Grails Plugin(http://www.grails.org/plugin/grails-melody) I use it to see if the site is being used before I pull down the service.
Hope that helps.
I tried Cloud Foundry in it's early days and found it a little rough. Sounds like that's still the case with 30+ minute deploys and the inability to restart your tomcat server. Half of your problems could be solved if you just created your own EC2 instance, installed tomcat and managed your own deployments. That'll let you bounce tomcat through shell access:
sudo /etc/init.d/tomcat6 restart
and redeploy your app
sudo /etc/init.d/tomcat6/stop
cp my.war /to/tomcat/dir
sudo /etc/init.d/tomcat6 start
or else you could do it through the tomcat admin console, but I find it to be flaky.
Regarding monitoring, there are a couple of ways you can do that. The easiest is to add CloudWatch monitoring to your system. That'll give you more insight into the performance of the application.
For more detailed monitoring regarding who's connecting to your app, I'd suggest looking at Google Analytics or Mint. If you need to get beyond that (with per user monitoring), you'll likely have to roll your own logging/tracking for what meets your needs. There are also other paid packages out there along the lines of Google Analytics and Mint that you can integrate with, but what fits your needs best, I can't say.
For actual monitoring of deployed system you can also use Hiperic HQ. It's a monitoring solution from Spring Source, who also are owners of Grails Framework.
It can manage, at your case:
tomcat server
database
linux
network
etc
btw redeploying app with changes is ok. it's a very bad practice to modify running app, on the production server.
I don't know if JMX and JConsole can help, but that might be a good way to see what the status of JMX-enabled POJOs is. Spring makes this easy to do.
Yes, you need to re-deploy your app when you change stuff in it, there's no way around that.
Deploy/re-deploy time has been cut significantly recently if using the grails plugin (btw, what version of the plugin do you use?) In some cases the upload time is as short as 15 seconds. Add 2-3 minutes for Amazon to spin up the instances and the deploy time is still pretty manageable. For re-deploy the instances don't have to be started, so it's even less than that.
To restart Tomcat login into your CloudFoundry account, click on the Deployment details, click on the instance that's running your Tomcat, and there will be a button "Restart service" that will do just that - restart Tomcat service.
You don't have to start your own EC2 instances in order to get a shell access. Copy the public DNS name of the instance from DeploymentDetails, and SSH into it using the private key you entered when registering for Cloudfoundry. Example:
ssh -i /path/to/gsg-keypair.pem root#your_instance_DNS_name

Is there a simpler way to deploy to WebSphere?

I have seen this question about deploying to WebSphere using the WAS ant tasks.
Is there a simpler way to do this? In the past I have deployed to Tomcat by dropping a war file into a directory. I was hoping there would be a similar mechanism for WebSphere that doesn't involve calling the IBM libraries or rely on RAD to be installed on your workstation.
Just a hint: if you activate "Log command assistance commands" in System Administration / Console preferences, you will get a logfile in the server log directory that contains the jython scripts for all actions you did on the console. So you can just deploy your stuff per console the first time, and then grab the commands for later and feed them into wsadmin.bat -lang jython "thecommandscomehere" for the next deployment.
There is the concept of WebSphere Rapid Deployment. It's supposed to be the same experience as what you describe for Tomcat.
One way to do it could be using Jython or jacl scripts. See those samples at IBM site.
[EDIT] Especially the wsadminlib.py.zip download near the bottom of the page contains a huge set of examples and helper functions to get you started.
WAS does provide a client jar containing some custom ant tasks. However they seem to be extremely bugy and dont work with remote servers.
IBM ANT TASK Javadoc
Netbeans also has support for was 6 and 6.1 but this again is still quite buggy, however it can be useful for generating some the bindings files etc.

Resources