As I was working on the Resin’s NetBeans plug-in I started to realize that we needed to change the model we use for plugins. Previously, we packaged Resin’s classes with the plugins. That presented us with number of challenges ranging from keeping the plugins in sync with the Resin’s code to having to release the plugins every time we release a new version of Resin.
The solution was in introducing a level of indirection that came in the form an updated Resin CLI interface. Initially, the interface is extended with the commands required for the plugin to work. That included the deployment commands and web-application administration commands.
Deployment commands allow use of CLI to deploy, undeploy, copy and list applications deployed on Resin server. Although we may still change a thing or two in options, the basic syntax will be maintained and will allow us to have Ant, Maven, Eclipse and NetBeans plugins go into a more stable state, with less frequent releases. That means developers who use the plugins will see them break very seldom.
To show some of the new deployment commands I’ll start with a deploy, list commands.
The complete syntax of the commands may be a bit involved, so I’ll use the set of options that is likely to be useful to everyone. A complete description is available with bin/resin.sh help e.g. bin/resin.sh help deploy.
Provided that there is a /tmp/test.war file, deploying it to Resin is done with ‘deploy’ command from Resin’s home directory.
Deployed production/webapp/default/test as /tmp/test.war to http://127.0.0.1:8087/hmtp
In the absence of a -name attribute the application will be deployed to a /test context. Deploying application to a specific context can be specified with a ‘-name’ option.
Deployed production/webapp/default/foo as /tmp/test.war to http://127.0.0.1:8087/hmtp
Parameter ‘-conf’ in the commands above is optional and is only used as an alternative to specifying ‘-address’ and ‘-port’ options. Options ‘-address’ and ‘-port’ can be specified when deploying to a remote server. The ip/hostname and http port of the server should be specified with an ‘-address’ and ‘-port’ options respectively.
Command ‘list’ lists all applications deployed on Resin.
Output ‘production/webapp/default/foo’ breaks down as following
production â€“Â stage
webapp â€“Â type of an application
default - host
foo - context
Before we look at the undeploy command let’s look at web-app administration commands ’start-webapp’, ’stop-webapp’ and ‘restart-webapp’.
Once deployed, an application is started automatically. Stopping an application can be done with ’stop-webapp’ command. A context to stop is specified as the last argument to the command: ‘foo’.
production/webapp/default/foo’ is stopped
A stopped application can be started again using either of the ’start-webapp’ or ‘restart-webapp’ commands.
‘production/webapp/default/foo’ is restarted
Finally, let’s look at an example of using an ‘undeploy’ command:
Undeployed foo from http://127.0.0.1:8087/hmtp
Resin configuration for deployment.
For resin to respond to deploy and web app management commands resin.xml needs to register deploy-service and an administrator account.
Configuring Deploy Service
<management> <deploy-service> </management>
Configuring an administrator account
<sec:AdminAuthenticator password-digest="none" xmlns:sec="urn:java:com.caucho.security"> <sec:user name="foo" password="test"/> </sec:AdminAuthenticator>
<resin xmlns="http://caucho.com/ns/resin" xmlns:admin="urn:java:com.caucho.admin" xmlns:sec="urn:java:com.caucho.security"> <management> <deploy-service/> </management> <cluster id="app-tier"> <sec:AdminAuthenticator password-digest="none"> <sec:user name="admin" password="secret"/> </sec:AdminAuthenticator> <admin:RemoteAdminService/> <server id="" port="8086"> <http port="8087"/> </server> <host id=""> <web-app-deploy path="webapps"/> </host> </cluster> </resin>