start/stop tomcat using maven - maven-2

How can i start/stop remote tomcat using maven. I am using cargo plugin which helps me in deploying the application , but doesn't provides the functionality to start/stop the remote tomcat.

Indeed, You can NOT start and stop Tomcat running remotely using Cargo, only deploy and undeploy your web application.
Actually, to my knowledge, there is currently nothing allowing to do this out of the box.
As explained here, the only way to make server "A" start or stop a service like Tomcat when the request comes from client "B" is that yet-another service needs to be available and already running on server "A". [...] and I don't know if such a service is available.
In this message, someone is describing such a solution (based on a socket listener) that you could maybe use (by doing some telnet through maven) but the message is quite old so it's likely outdated and the link pointing to the code seems to be dead. I didn't check out the whole thread, maybe there are other ideas.
If you are using windows, remote service sharing is another possible solution as described here. But, again, this would require some work on your side.

From a security standpoint, it's only possible in this way...
Linux: use an SCP or script via SSH Client (putty), then '$CATALINA_HOME/bin/shutdown.sh'
Windows: use sc command, like "sc \192.168.10.10 stop tomcat6"
Quick and clean!

You can try to use the maven tomcat plugin or if it does not give you everything you need, you can always use an ant task here is a reference on the task

You can use Cargo Daemon web-application. It runs on the remote machine and can start/stop tomcat for you (as well as deploy an app). You just need to configure Cargo plugin and call mvn:daemon-start. Here is the link: http://cargo.codehaus.org/Cargo+Daemon. It's easier to start with provided Cargo Daemon archetype: http://cargo.codehaus.org/Maven2+Archetypes#Maven2Archetypes-daemon

Try this useful Plugin
Afterwards try this:
mvn tomcat:start
and
mvn tomcat:stop

Related

Running a Raku Cro app as a persistent service

I'd like to run a perl6/raku Cro app as a service behind a frontend webserver.
Just running cro run won't handle restarting after segfaults & reboots.
Previously with perl5 I've used FastCGI - however Cro::HTTP::Server's Cro::HTTP::Server.new().start() idiom doesn't look compatible with FastCGI::Native's while $fcgi.accept() {} example.
The service.p6 generated by cro stub does have a SIGINT handler, however I'm unsure whether this is sufficient to point to it in a systemctl service, i.e.
[Service]
ExecStart = /path/to/service.p6
How are people currently hosting Cro apps?
cro run is intended as a development tool, not a deployment one, and so is indeed not a good choice for hosting the services.
All of the Cro services I directly take care of are containerized (some guidance on that here) and then run on a hosted Kubernetes cluster. Kubernetes takes care of the automatic restarts, rolling out new versions, etc. I'm also aware of docker-compose being used in place of Kubernetes, which I guess works, though I believe that's also considered as primarily a development tool.
Setting it up as a systemctl service should also work fine, provided that's configured to always restart. However, it seems that you'd want to handle SIGTERM for the clean shutdown to work instead of SIGINT (nothing wrong with handling both).
I do also place a frontend web server in front of Cro (using Apache, though nginx would be a fine choice too), and also use that to do some caching of static content also (using content-control in my routes to describe the cachability).

How to halt provisioning of one VM until another VM is done?

Using Vagrant+Chef Solo I'm setting up two VMs: #1 is a TeamCity server, #2 is a TeamCity agent. Provisioning is done by first installing the TeamCity server package on VM #1, then the agent VM is booted and requests data from the server which is used to install the agent. That whole thing works fine.
But now I want to alter the server after the agent is done provisioning. I want to modify the server's database directly, to change an attribute that is only available after the agent has spun up. But is there a way for one VM's provisioning to trigger another VM? Once the agent is done I'd like to somehow resume provisioning the server, so I can make the database edit..
Any thoughts, recommendations, or feedback welcomed. I'm new to Vagrant, Chef, and TeamCity, so there's a chance I'm missing a much easier solution.
* Why do I want to edit the DB directly you may be wondering? TeamCity agents must be authorized before they can be used, and I want to do this programmatically. The solution I've found is to directly edit the DB, because authorization functionality is not exposed via the TeamCity REST API (as far as I can tell)
If you can test the agent is installed/answering, you may add a ruby block looping over this test before continuing the recipe execution.
This loop should have a sleep and a counter to avoid infinite loops.
I've no knowledge of teamcity, so can't tell if it's the best way.
In general, Chef is designed to manage your system, not simply provision it (though this is less true in the modern Cloud world with "golden image" strategies). Nonetheless, in your case, you best bet is to just setup chef-client as a service that runs every 15 minutes. Once the client has finished provisioning, the next run of the server will be able to authorize it.
If you really want to "trigger" the one from the other, you'd need either do that externally with something like etcd or consul, or you would need to setup an ssh keypair between the boxes and add a ruby_block on the client that either does the database modification directly, or calls chef-client on the server.

ActiveMQ integration with Weblogic

I have been tasked with integrating ActiveMQ with Weblogic (v 10.3.6.0).
I have downloaded ActiveMQ v 5.10.0, installed it upon the server and browsed to localhost:8161/admin in order to confirm that ActiveMQ is running.
I'm not sure how to progress from here in order to complete my goal. This link:
http://activemq.apache.org/weblogic-integration.html
.. suggests that there are two approaches to deploying ActiveMQ on Weblogic: either deploying a broker as an application or using a J2EE Connector. I'm investigating the latter approach as I have now installed ActiveMQ on the server (which means that I already have a running broker, I assume) but can't find much useful information on the Net about how to do this.
This page:
http://activemq.apache.org/resource-adapter.html
... suggests that it can be done via a JCA Resource Adapter but again does not give any details on how to do it.
If anyone has any advice or guidance, I'd appreciate it.
Thanks in advance.
Did you try this: http://activemq.apache.org/how-to-deploy-activemq-ra-versionrar-to-weblogic.html?
You will have to grab the resource adapter from maven.
Not that your local installation will help you much expect for testing etc. You should deploy AMQ inside WebLogic if you want it to serve as the JMS layer of WebLogic - otherwise a totally standalone installation is fine. But then you're done, and I suspect you want the deployed version non the less.

Remotely start stop jboss server

I have a requirement to write a java program to remotely start stop a jboss server on request. Can anyone please suggest how could it be done? One option could be invoke start/stop script but this java program(may be servlet or jsp) exists on different machine. We are using jboss server 7.
A simple method to start and stopping Jboss remotely can be done with the run.sh and shutdown.sh script, by pointing to the right host and port. If you are on Linux you can run:
rsh user#host /path/to/jboss/bin/run.sh
rsh user#host /path/to/jboss/bin/shutdown.sh
You can also execute a Shell command with Java, you can use Runtime exec mewthod:
Runtime.getRuntime().exec("shell command here");
See this complete answer for more details on Java exec method.
A better alternative I would suggest, is to use JMX-console programmatically, you can stop/restart a Jboss intance by invoking the shutdown method on the Server MBean. JMX approach is more powerful because you can monitor and manage every aspect of the Jboss runinng instanace (like logging, memory or cpu). See this to start.
I've created a snippet to ease your start, see this working solution http://snipt.org/Ahhjh4
Remember:
create a Jboss user on the Jboss instance using add-user.sh (JBOSS_HOME/bin)
include the jboss-client.jar in your client class-path (the jar is in JBOSS_HOME/bin/client)
Good luck!

jboss - how to automate retrying deployment of war file

When running jboss 7.1 as a windows service (or not), it occasionally takes more than one try to successfully deploy a war file. This is not a problem when starting jboss manually since restarts are easy. However, when jboss runs as a windows service and it is restarted automatically (due to a windows patch), jboss itself may launch, but the war may not.
Is there any way to cause jboss to retry deploying the war after it fails the first time - for example, by changing a setting in standalone.xml?
There are to ways to fix your problem.
1) go to standalone.xml (or whatever configuration you are running), find deployment-scanner and add/modify attribute deployment-timeout in seconds
2) Deploy your application as managed deployment, you can do that if you deploy trough admin console or via cli with deploy command. This way deployment will then be "managed" and will always be deployed and wont be using deployment scanner and its timeouts.
I recommend you to use deploy as managed deployment as deployment scanner is not really recommend to be used in production environments as it adds additional IO load on filesystem.
It is great for development / testing scenarios but should be avoided in production if possible.