Note: make sure you have defined a user with role manager in tomcat/conf/tomcat-users.xml).
We will illustrate this tutorial with a sample web application name HelloExample. The
WEB-INF/web.xml
within HelloExample.war contains a servlet initialization parameter named greeting
whose value has been templatized with the KwateeSDCM deployment variable %{HELLO_MESSAGE}
so that we may easily customize the deployment without modifying the war archive.You can download the HelloExample.war package here.
This tutorial relies on
curl
to automate the start/stop of the web application. If your tomcat server is running on windows you can download a windows curl executable here and make it accessible on the server's path. 1. Create a sdcm package
- Create a new package named
HelloExample
- Create a new version named
v1.0
- Select and upload the archive
HelloExample.war
- Create an executable named
war
- In the Launch script field, enter:
curl --basic --user %{TOMCAT_USER}:%{TOMCAT_PASSWORD} http://localhost:8080/manager/start?path=/HelloExample
(single command line with a <space> before http...) - In the Stop script field, enter:
curl --basic --user %{TOMCAT_USER}:%{TOMCAT_PASSWORD} http://localhost:8080/manager/stop?path=/HelloExample
(single command line with a <space> before http...) - Save
2. Define the target server(s)
- Create a new server named
MyTomcatHost
- Select the appropriate platform
- Enter the IP address of the server (e.g.
localhost
) - Enter the SRM-level user name/password to connect to your server
Make sure the user you select has write privileges on tomcat's webapps directory
(i.e. /usr/local/tomcat/webapps) as well as on kwatee's working directory defined in sdcm's system parametersdcm_root_dir
(defaults to /kwatee) - Save
- Repeat the above for as many servers as you like
3. Define the environment
- Create a new environment named
hello_environment
- Add MyTomcatHost server to deployment
- Add HelloExample package to
MyTomcatHost
server and set active version tov1.0
- Save, then Configure SDCM Variables
- Add variable named
HELLO_MESSAGE
with valueHello world
- Add variable named
TOMCAT_USER
with valuemanager
(or whatever your manager user is) - Add variable named
TOMCAT_PASSWORD
with valuepassword
- Add variable name
sdcm_deployment_dir
with value
/usr/local/tomcat/webapps
(or whatever you tomcat path is) - Save
4. Deploy and test
- Go to the Environments list and manage environment
hello_environment
- Install the package
- Point your browser to
http://localhost:8080/HelloExample
5. Update the configuration and re-deploy
- Go back to the deployment variables configuration and change the
HELLO_MESSAGE
value toHello new world
- Save and return to environment management
- Install the package
- Point your browser to
http://localhost:8080/HelloExample
The steps of this tutorial are illustrated in this video
No comments:
Post a Comment