Building and Deploying A Package To install your customized code to the production server you will need to package the codebase with RPM. RPM is available for most flavours of UNIX, including &RHEL; and Solaris. This section outlines the steps for building a new RPM and installing it on your production or staging server. Building a package Deployment to a live server is done by creating a package from a tested and known good instance and installing it on your live servers. Setting up an Instance An RPM is built from a staging or development instance. You will have a dev directory setup which contains all the code you intend to run on your live server. The first step is to ensure the quality of the instance you are building from. First you should do a clean and rebuild of your instance. With your environment setup for appropriate instance using ccm-profile, execute the following commands from the top level dev directory: ccm-stop ant ant ccm-start Once this has completed you should test it extensively, but concentrating specifically on anything you may have changed since the last build. When you are happy with it, you can create a package. Creating a package Before creating a package, you should first increment the version or release number as described in . Be sure to commit your change to CVS if you are using it. Creating a package only requires a single command. In the top level dev directory there will be a file called rollingbuild.sh. To execute it, type: ./rollingbuild.sh rollingbuild.sh does a complete build from scratch and can potentially take a long time to run. By default it also builds more than one type of package. To make it run quicker, you can use the following command instead: CCM_DIST_NOZIPS=1 ./rollingbuild.sh RPM version You will want to increment the release and version numbers of your packages everytime you create a new build. You can do this by editing project.xml or application.xml. Please see . If you do not increment the release number you will not be able to upgrade an existing installation without using the rpm --force option. You should always increment the release number no matter how insignificant the change is. Having good accounting in terms of releases allows you to revert to older versions. File locations rollingbuild.sh creates a number of rpms which are arranged according to convention. All of the rpms are created in the directory /var/ccm-devel/rpm/username/RPMS/noarch. The source RPM is in /var/ccm-devel/rpm/username/SRPMS/ When it finishes, rollingbuild will have created a number of packages. projectname-x.x.x-x.noarch.rpm - This is the binary RPM of the code base. projectname-servlet-resin-x.x.x-x.noarch.rpm - This is the RPM for running your project with the Resin servlet container. projectname-servlet-tomcat3-x.x.x-x.noarch.rpm - This is the RPM for running your project with the Tomcat servlet container. projectname-devel-tomcat3-x.x.x-x.noarch.rpm - This is the RPM for creating another project that extends the current project. This will install code in /usr/share/ccm-devel/project. projectname-doc-x.x.x-x.noarch.rpm - This is the javadoc generated from your project code. It will include all the APLAWS and &CCM; Javadoc. projectname-x.x.x-x.src.noarch.rpm - This is the source RPM for your project. Installing your RPM Once you have created your RPM you will need to install it on your staging or production machine. Here are the steps for installing your RPMS, you will need to be logged in as the root user. Quick steps for the impatient Copy two RPMs, projectname-x.x.x-x.noarch.rpm, and projectname-servlet-resin-x.x.x-x.noarch.rpm to your staging server. Install the two RPMs at once by running the following command. rpm -Uvh projectname-x.x.x-x.noarch.rpm projectname-servlet-resin-x.x.x-x.noarch.rpm Copy the file /etc/projectname.cfg-resin to /etc/projectname.cfg. Edit /etc/projectname.cfg in the same way you edited config.vars. Update the configuration files for your server by running projectname-configure.pl. This is similar to running ant make-init. /usr/sbin/projectname-configure.pl /etc/projectname.cfg The server should restart automatically when the configuration files are changed. If this does not happen you can restart the server manually with the init script. /etc/init.d/projectname restart # stop|start Installing the RPMS: <filename><replaceable>projectname</replaceable>-x.x.x-x.noarch.rpm</filename> You will need to install the two RPMs projectname-x.x.x-x.noarch.rpm, and projectname-servlet-resin-x.x.x-x.noarch.rpm together as the two are interdependent. projectname-x.x.x-x.noarch.rpm will install your code in /var/www/projectname where it will be used by your application server. This RPM also installs the init file /etc/init.d/projectname, the configuration script /usr/sbin/projectname-configure.pl, and the log directory /var/log/projectname. Installing the RPMS: <filename><replaceable>projectname</replaceable>-servlet-resin-x.x.x-x.noarch.rpm</filename> The servlet RPM will install configuration files and wrapper scripts for controlling the servlet container. Specifically it will install the following files: /usr/share/projectname/bin/resin/run-apache.sh.in /usr/share/projectname/bin/resin/run-resin.sh.in /usr/share/projectname/bin/resin/run.sh.in /usr/share/projectname/conf/resin /usr/share/projectname/conf/resin/httpd-resin-vhost.conf.in /usr/share/projectname/conf/resin/resin-back.conf.in /usr/share/projectname/conf/resin/resin-front.conf.in These files are templates for your installation. When you run the command /usr/sbin/projectname-configure.pl copies of these files will be placed in /var/www/projectname/conf and /var/www/projectname/bin. They will also be edited to reflect the parameters you set in /etc/projectname.cfg The <filename><replaceable>projectname</replaceable>.cfg</filename> Once the RPMs are installed you will need to edit the configuration file for your server. The template for the config file is /etc/projectname.cfg-resin. Copy this file to /etc/projectname.cfg and edit the parameters much like how you edited config.vars. Some of the parameters are not in config.vars and you will need to change the values depending on how your Resin and HTTP servers are set up. Below is an example of a configuration file for a production installation with two Resin application servers and one Apache front end. The values you need to change in addition to what what you find in config.vars is emphasised with additional comments. The Resin servers are called resin1.example.com and resin2.example.com and the Apache server is called apache.example.com. <command>hostname</command> The hostnames for the servers need to be exactly as they appear when you run the hostname command. If you want to change the default behavior of hostname to return the short name or the fully qualified domain name here is what you can do: Edit /etc/sysconfig/network and change HOSTNAME to be the fully qualified domain name. You can also use the gui tools netconfig and redhat-config-network to do this. These changes will only take effect after the machine has been restarted. To change it at runtime pass an argument to hostname as root. $ hostname resin1.example.com You can test this by running hostname with no arguments. ########################################## # APLAWS Master configuration file # ######################################### servlet-container = resin ## This is set to servlet23 by default but should be resin servlet-webxml = resin # NB: all hostnames used should be # the fully qualified name as returned # by the 'hostname' command with no arguments. #################################### # UNIX system level configuration # Installation directory for resin ## This should be the directory of your Resin installation resin-home = /opt/resin/2.1.8 # Installation directory for this app app-home = /var/www/aplaws # Directory containing the base runtime & config files runtime-home = /usr/share/aplaws # UNIX accounts to run as user = servlet group = servlet # Whereever you installed JDK 1.3.1 # java-home = /usr/j2se # java-home = /usr/java/jdk1.3.1 ## The java-home should point to $JAVA_HOME java-home = /opt/IBMJava2-131 # Userinputly tell java to use more memory # # For Sun's JDK, on a machine with 1GB #jre-args = -J-client -J-Xss128k -J-Xms512m -J-Xmx512m -J-XX:NewSize=128m -J-XX:MaxNewSize=128m # # For IBM's JDK on a machine with 256MB #jre-args = -J-Xms128m -J-Xmx128m jre-args = -J-Xms1536m -J-Xmx1536m # The hostname of the front end apache box apache = apache.example.com # The hostnames of the back end resin boxes resin = resin1.example.com resin = resin2.example.com # The SRUN ports for apache to talk to the resin # boxes. The 'hostname:port' pair designates which # srun port each resin instance listens on. # If there is a firewall, between the resin and # apache boxes, a second 'hostname:port' pair # specifies the host and port of the firewall # # eg1. no firewall srun = resin1.example.com:6802 srun = resin2.example.com:6802 # eg2. with firewall #srun = resin1.example.com:6082, firewall:6802 #srun = resin2.example.com:6082, firewall:6803 # Turn on http listening on either apache # or resin boxes. Only need http port on # the resin boxes for debugging purposes http = apache.example.com:80 # Only for debugging http = resin1.example.com:8080 http = resin2.example.com:8080 # ACS initialization file admin-answer = 6 admin-email = admin@example.com admin-forename = Administrator admin-password = 123456 admin-question = 12345 admin-surname = Account cache-expiry = 900 cache-peers = "http://resin1.example.com:8080" caching-active = yes db-pass = aplaws_xyz db-pool = 150 db-user = aplaws debug-mode = false default-locale = en_US default-scheme = http developer-support = false dispatcher-context-path = dispatcher-servlet-path = dmi-active = false dmi-data-model-file = "/WEB-INF/sql/ccm-core/default/dmi/dmi-create.sql" dmi-xml-files = { "core-dmi.xml", "/WEB-INF/sql/ccm-core" } host-name = apache.example.com hostname = apache.example.com jdbc-url = jdbc:postgresql://postgres.example.com/aplaws log-dir = /var/log/aplaws log-level = warn log-size = 1000000 login-stylesheet = login_en.xsl lucene-index-location = /var/www/aplaws/lib/lucene-index permissionsDMLChecking = false search-intermedia-enabled = false search-lucene-enabled = true search-lucene-indexer-id = 2 server-name = apache.example.com server-port = 80 sitename = APLAWS smtp-host = localhost state-dir = /var/www/aplaws/lib subsite-dispatcher-class = com.arsdigita.ui.login.SubsiteDispatcher xslt-engine = Saxon xslt-timeout = 60000 # WCT CMS Initialization File content-digest-sender = article-digest@example.com forms-content-digest-sender = forms-digest@foo.com inso_filter_works = 0 publish-to-fs-servers = "http://resin1.example.com/", "http://resin2.example.com/" publish-to-fs-source = "http://resin2.example.com/" publish-to-fs-this-server = "http://resin2.example.com/" search-engine = lucene # Version: $Id: building-packages.sgml 287 2005-02-22 00:29:02Z sskracic $ $Date: 2004/07/29 $ adminCanEditPosts = true authorCanEditPosts = true digestUserEmail = digests replyHostName = apache.example.com # Navigation initialization file default-content-section-url = "/content/" # System Properties project-name = aplaws <command>/usr/sbin/<replaceable>projectname</replaceable>-configure.pl</command> Once you have edited /etc/projectname.cfg-resin you can run /usr/sbin/projectname-configure.pl to generate the config files and the run scripts for your server to use. Make sure that you do not get errors after you run this command. /usr/sbin/projectname-configure.pl copies files from /usr/share/projectname/bin/resin/ and replaces the parameter values with what you have set in the configuration file and places them in /var/www/projectname/conf. It also generates the wrapper run scripts in /var/www/projectname/bin. <command>/etc/init.d/<replaceable>projectname</replaceable></command> Once the configuration files and the wrapper scripts are written you can start, stop, and restart your sever using /etc/init.d/projectname. The log files are located in your specified directory, by default /var/log/projectname. You should tail -f /var/log/projectname/*.log to monitor the progress of your server startup. <command>/etc/init.d/<replaceable>projectname</replaceable></command> restart When you restart the server the command will pause for a number of seconds to wait for the application server to completely exit.