Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 14 Next »

Overview

Describes how to set up and deploy the application to the WCI term-server.com server.

Diagram

Details

  1. Log into the server 10.230.174.16
    1. You'll need to be able to sudo su - to root and ec2-tomcat.

  2. Install and configure software as root (nginx, tomcat7 (and webapps), mysql-server-5.5 (and client), Java/jdk (including devel), maven, git, svn, etc.
    1. Edit the /etc/init.d script to comment out the top part that forces running as root

    2. Edit the /etc/init.d script to use this so the ec2-user can write the pid file:

      CATALINA_PID="/var/lib/tomcat7/$NAME.pid"
      
      # also change all instances of /var/run to /var/lib/tomcat7 
    3. Set permissions of the tomcat installation to the "ec2-tomcat"user

      # for each linked directory in /usr/share/tomcat7 d
      chown -R ec2-tomcat $dir
      chgrp -R ec2-user $dir
      
      
      Edit /etc/init.d/tomcat7 to use the following
      * TOMCAT_USER=ec2-tomcat
      * TOMCAT_GROUP=ec2-user
      
      
      Also edit /etc/tomcat7.conf
      * CATALINA_PID=/var/lib/tomcat7/tomcat7.pid
      * TOMCAT_USER=ec2-tomcat
      * TOMCAT_GROUP=ec2-user
      
      
      Make sure all the "chown" commands in the script change to group to $TOMCAT_USER

       

      NOTE: the tomcat user can start/stop the server with "/usr/sbin/tomcat7 start/stop".
      HOWEVER: if the process was started by root, it will likely have to be killed by root first..  we're working on this. 

       

  3. Tomcat must be configured to pass "run.config" environment variable to the application
    1. One way to do this is to invoke the java command with -Drun.config=/home/ihtsdo/data/config.properties
      (e.g. edit this in /usr/share/tomcat7/conf/tomcat7.conf and add to JAVA_OPTS)
    2. Also add -Xmx2500M to JAVA_OPTS in the tomcat startup script.
    3. NOTE: development environments must also be configured as such

  4. Tomcat must be configured to support POST requests of size > 2MB
    1. Edit server.xml and add  maxPostSize="50000000" to each <Connector> element.

  5. Tomcat must be configured to support following of links.  Make sure any Context tags in the configuration contain  allowLinking="true".
    1. Edit context.xml to add this parameter to the Context tag.

  6. To enable tomcat manager, add this to tomcat-users.xml file.

    <role rolename="manager-gui" />
    <user name="tomcat" password="********" roles="manager-gui" />
    <role rolename="protected" />



  7. Make sure you have MAVEN_OPTS set 
    1. e.g. -XX:MaxPermSize=512m -Xmx5000m
       
  8. Nginx Configuration
    1. Install the SSL keys as root in the appropriate places (if SSH needed)
    2. Add a file "snomed.term-server.com.conf" to /etc/nginx/conf.d
    3. Add a Valve to tomcat to handle proxy headers.

              <Valve className="org.apache.catalina.valves.RemoteIpValve"
                     remoteIpHeader="x-forwarded-for"
                     remoteIpProxiesHeader="x-forwarded-by"
                     protocolHeader="x-forwarded-proto"/>
    4. Edit /etc/nginx/nginx.conf and add "client_max_body_size 50M;" to the "http" context.
    5. /etc/nginx/nginx.conf contains the master configuration - see for details
    6. For more info click here
       
  9. MySQL Configuration

    1. When configuring the database URL in config.properties, use ?autoconnect=true to avoid connection issues

    2. Also (as root) edit the my.cnf file for your platform and add this to the mysqld section.

      [mysqld]
      ...
      wait_timeout = 230400
      interactive_timeout = 230400
  10. As the MySQL root user, create an OTF user with the mysql client

    CREATE USER 'otf'@'localhost' IDENTIFIED BY 'otfpwd';
    GRANT ALL privileges ON *.* TO 'otf'@'localhost';
  11. As the MySQL root user, create a database in the mysql client

    CREATE DATABASE tsdb
      DEFAULT CHARACTER SET utf8
      DEFAULT COLLATE utf8_general_ci;
    CREATE DATABASE tsdbtest
      DEFAULT CHARACTER SET utf8
      DEFAULT COLLATE utf8_general_ci;
    GRANT ALL ON tsdb.* TO 'otf';
    GRANT ALL ON tsdbtest.* TO 'otf';
  12. Get code 

    cd
    mkdir code
    cd code
    git clone https://github.com/WestCoastInformatics/SNOMED-Terminology-Server.git .
     
    # switch to dev branch - for UAT
    git checkout develop
     
    # switch to dev branch - for PROD
    git checkout master
  13. Prepare the environment (set your shell up with these ENV variables):

    JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64
    MAVEN_OPTS=-Xmx3000M
    SERVER_HOME=/home/ec2-tomcat/code
    SERVER_CONFIG=/home/ec2-tomcat/config/config.properties
    SERVER_CONFIG_TEST=/home/ec2-tomcat/config/config.properties.test



  14. The sample data lives in the "config" project.   Install in the ~/data directory

    cd
    mkdir data
    cp -r code/config/src/main/resources/* data
  15. Prepare a config file

    cd
    mkdir config
    cp -r code/config/src/main/resources/config.properties.prod ~/config/config.properties
    # edit as needed
    # in particular, set base.url to the base URL for this environment - needed by Swagger. e.g.
    #   base.url=http://snomed.terminology.tools



  16. Build the environment using the prepared configuration as the build.config

    cd
    cd code
    mvn -Dbuild.config=~/config/config.properties clean install



  17. Prepare the tomcat indexes location

    # To clean up the indexes do this (as root)
    /bin/rm -rf /var/lib/tomcat7/indexes
    mkdir /var/lib/tomcat7/indexes
    chmod -R ga+rwx /var/lib/tomcat7/indexes
    chown -R ec2-tomcat:ec2-user /var/lib/tomcat7/indexes
     
    # Ensure the config.properties file used to run the application has this setting
    hibernate.search.default.indexBase=/var/lib/tomcat7/indexes/
  18. Create and Load the data

    cd
    mkdir bin
    cp ~/code/admin/loader/scripts/* bin
    chmod 775 bin/*
    cd bin
    ./load.csh >&! load.log
  19. Stop tomcat, clear cache,and remove the currently deployed .war files (and associated folders).

    # Stop the tomcat7 server
    service tomcat7 stop
    /bin/rm -rf /var/lib/tomcat7/work/Catalina/localhost/term-server-rest
    /bin/rm -rf /var/lib/tomcat7/webapps/term-server-rest
    /bin/rm -rf /var/lib/tomcat7/webapps/term-server-rest.war
  20. Update the database (this needs to go into the reload page):

    mvn clean install -Drun.config=/home/ihtsdo/config/config.properties -Dhibernate.hbm2ddl.auto=update
  21. Update file modification date to prevent caching issues.

    cd ~/code
    set date = `date +%Y%m%d%H%M`
    touch -t $date `find . -name "*"`
  22. Build Rest and deploy war

    cd ~/code/rest
    mvn -Drun.config=$SERVER_CONFIG -Dbase.url=http://snomed.terminology.tools clean install
    /bin/cp -f target/term-server-rest*war /var/lib/tomcat7/webapps/term-server-rest.war
  23. Start service

    service tomcat7 start
  24. Run the integration tests.

    cd
    cd code/integration-test
    mvn -DskipTests=false -Drun.config.test=$SERVER_CONFIG_TEST test
  • n/a

 


  • No labels