diff --git a/Dockerfile b/Dockerfile
index e2a2887..4b2179c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,27 +1,35 @@
FROM kbase/sdkbase2:latest AS build
-# Multistage Build Setup
-
-RUN cd /tmp && \
- git clone https://github.com/kbase/jars
-
-COPY . /tmp/user_profile
-
-# Bypass the makefile, which has perl dependencies, and just use
-# the underlying ant compile and ant buildwar
-RUN cd /tmp/user_profile && \
- ant compile && \
- ant buildwar
+WORKDIR /tmp/up
+
+# dependencies take a while to D/L, so D/L & cache before the build so code changes don't cause
+# a new D/L
+# can't glob *gradle because of the .gradle dir
+COPY build.gradle gradlew settings.gradle /tmp/up/
+COPY gradle/ /tmp/up/gradle/
+RUN ./gradlew dependencies
+
+# Now build the code
+# copy the deployment dir first since it's unlikely to change often
+COPY deployment/ /kb/deployment
+COPY jettybase /kb/deployment/jettybase
+COPY src /tmp/up/src/
+COPY war /tmp/up/war/
+RUN ./gradlew war
+
+# Build the deployment directory
+ENV DEPL=/kb/deployment/jettybase
+RUN mkdir -p $DEPL/webapps
+RUN cp /tmp/up/build/libs/user_profile.war $DEPL/webapps/ROOT.war
FROM kbase/kb_jre:latest
+
# These ARGs values are passed in via the docker build command
ARG BUILD_DATE
ARG VCS_REF
ARG BRANCH=develop
-COPY deployment/ /kb/deployment/
-COPY jettybase/ /kb/deployment/jettybase/
-COPY --from=build /tmp/user_profile/dist/UserProfileService.war /kb/deployment/jettybase/webapps/ROOT.war
+COPY --from=build /kb/deployment/ /kb/deployment/
# The BUILD_DATE value seem to bust the docker cache when the timestamp changes, move to
# the end
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 93e4e63..0000000
--- a/Makefile
+++ /dev/null
@@ -1,163 +0,0 @@
-#port is now set in deploy.cfg
-SERVICE_PORT = $(shell perl server_scripts/get_deploy_cfg.pm UserProfile.port)
-SERVICE = user_profile
-SERVICE_CAPS = UserProfile
-SPEC_FILE = UserProfile.spec
-CLIENT_JAR = UserProfileClient.jar
-WAR = UserProfileService.war
-URL = https://kbase.us/services/user_profile/rpc
-DEFAULT_SCRIPT_URL = $(URL)
-
-#End of user defined variables
-
-GITCOMMIT := $(shell git rev-parse --short HEAD)
-TAGS := $(shell git tag --contains $(GITCOMMIT))
-BRANCH := $(shell git symbolic-ref --short HEAD)
-TOP_DIR = $(shell python -c "import os.path as p; print p.abspath('../..')")
-
-TOP_DIR_NAME = $(shell basename $(TOP_DIR))
-
-DIR = $(shell pwd)
-
-ifeq ($(TOP_DIR_NAME), dev_container)
-include $(TOP_DIR)/tools/Makefile.common
-endif
-
-DEPLOY_RUNTIME ?= /kb/runtime
-JAVA_HOME ?= $(DEPLOY_RUNTIME)/java
-TARGET ?= /kb/deployment
-SERVICE_DIR ?= $(TARGET)/services/$(SERVICE)
-GLASSFISH_HOME ?= $(DEPLOY_RUNTIME)/glassfish3
-SERVICE_USER ?= kbase
-
-ASADMIN = $(GLASSFISH_HOME)/glassfish/bin/asadmin
-
-ANT = ant
-
-
-SRC_PERL = $(wildcard scripts/*.pl)
-BIN_PERL = $(addprefix $(BIN_DIR)/,$(basename $(notdir $(SRC_PERL))))
-
-# make sure our make test works
-.PHONY : test
-
-default: build-bin build-docs build-bin
-
-# fake deploy-cfg target for when this is run outside the dev_container
-deploy-cfg:
-
-
-
-SCRIPTBINDESTINATION = $(DIR)/bin
-ifeq ($(TOP_DIR_NAME), dev_container)
-include $(TOP_DIR)/tools/Makefile.common.rules
-SCRIPTBINDESTINATION = $(TOP_DIR)/bin
-endif
-
-build-libs:
- $(ANT) compile
-
-build-bin: $(BIN_PERL)
-
-build-docs: build-libs
- mkdir -p docs
- @#$(ANT) javadoc
- pod2html --infile=lib/Bio/KBase/$(SERVICE_CAPS)/Client.pm --outfile=docs/$(SERVICE_CAPS).html
- rm -f pod2htm?.tmp
- cp $(SPEC_FILE) docs/.
-
-compile: compile-typespec compile-typespec-java
-
-compile-java-client:
- @# $(ANT) compile_client
-
-compile-typespec-java:
- kb-sdk compile $(SPEC_FILE) \
- --out . \
- --java \
- --javasrc src \
- --javapackage us.kbase \
- --javasrv \
- --url $(URL)
-
-compile-typespec:
- kb-sdk compile $(SPEC_FILE) \
- --plclname Bio::KBase::$(SERVICE_CAPS)::Client \
- --pyclname biokbase.$(SERVICE).client \
- --jsclname javascript/$(SERVICE_CAPS)/Client \
- --out lib \
- --url $(URL)
-
-test: test-client test-service test-scripts
-
-test-client: test-service
- @# $(ANT) test_client_import
-
-test-service:
- $(ANT) test
-
-test-scripts:
-
-
-deploy: deploy-client deploy-service
-
-deploy-client: deploy-client-libs deploy-docs deploy-perl-scripts
-
-deploy-client-libs:
- mkdir -p $(TARGET)/lib/
- cp dist/client/$(CLIENT_JAR) $(TARGET)/lib/
- cp -rv lib/* $(TARGET)/lib/
- echo $(GITCOMMIT) > $(TARGET)/lib/$(SERVICE).clientdist
- echo $(TAGS) >> $(TARGET)/lib/$(SERVICE).clientdist
-
-deploy-docs:
- mkdir -p $(SERVICE_DIR)/webroot
- cp -r docs/* $(SERVICE_DIR)/webroot/.
-
-deploy-service: deploy-service-libs deploy-service-scripts deploy-cfg
-
-deploy-service-libs:
- $(ANT) buildwar
- mkdir -p $(SERVICE_DIR)
- cp dist/$(WAR) $(SERVICE_DIR)
- mkdir $(SERVICE_DIR)/webapps
- cp dist/$(WAR) $(SERVICE_DIR)/webapps/root.war
- echo $(GITCOMMIT) > $(SERVICE_DIR)/$(SERVICE).serverdist
- echo $(TAGS) >> $(SERVICE_DIR)/$(SERVICE).serverdist
-
-deploy-service-scripts:
- cp server_scripts/glassfish_administer_service.py $(SERVICE_DIR)
- cp server_scripts/jetty.xml $(SERVICE_DIR)
- server_scripts/build_server_control_scripts.py $(SERVICE_DIR) $(WAR)\
- $(TARGET) $(JAVA_HOME) deploy.cfg $(ASADMIN) $(SERVICE_CAPS)\
- $(SERVICE_PORT)
-
-deploy-upstart:
- echo "# $(SERVICE) service" > /etc/init/$(SERVICE).conf
- echo "# NOTE: stop $(SERVICE) does not work" >> /etc/init/$(SERVICE).conf
- echo "# Use the standard stop_service script as the $(SERVICE_USER) user" >> /etc/init/$(SERVICE).conf
- echo "#" >> /etc/init/$(SERVICE).conf
- echo "# Make sure to set up the $(SERVICE_USER) user account" >> /etc/init/$(SERVICE).conf
- echo "# shell> groupadd kbase" >> /etc/init/$(SERVICE).conf
- echo "# shell> useradd -r -g $(SERVICE_USER) $(SERVICE_USER)" >> /etc/init/$(SERVICE).conf
- echo "#" >> /etc/init/$(SERVICE).conf
- echo "start on runlevel [23]" >> /etc/init/$(SERVICE).conf
- echo "stop on runlevel [!23]" >> /etc/init/$(SERVICE).conf
- echo "pre-start exec chown -R $(SERVICE_USER) $(TARGET)/services/$(SERVICE)" >> /etc/init/$(SERVICE).conf
- echo "exec su kbase -c '$(TARGET)/services/$(SERVICE)/start_service'" >> /etc/init/$(SERVICE).conf
-
-docker_image:
- IMAGE_NAME=kbase/user_profile:$(BRANCH) bash -x hooks/build
-
-undeploy:
- -rm -rf $(SERVICE_DIR)
- -rm -rfv $(TARGET)/lib/Bio/KBase/$(SERVICE)
- -rm -rfv $(TARGET)/lib/biokbase/$(SERVICE)
- -rm -rfv $(TARGET)/lib/javascript/$(SERVICE)
- -rm -rfv $(TARGET)/lib/$(CLIENT_JAR)
-
-clean:
- $(ANT) clean
- -rm -rf docs
- -rm -rf bin
- @#TODO remove lib once files are generated on the fly
diff --git a/build.gradle b/build.gradle
index 7cd9b97..3a23aa4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -13,9 +13,6 @@ var DEFAULT_URL = "https://ci.kbase.us/services/user_profile/rpc"
var LOC_UP_SPEC = "$rootDir/UserProfile.spec"
var LOC_DOC_HTML = "$rootDir/docshtml"
-// TODO NOW update dockerfile
-// TODO NOW delete build.xml and Makefile
-
repositories {
mavenCentral()
}
diff --git a/build.xml b/build.xml
deleted file mode 100644
index 2c56601..0000000
--- a/build.xml
+++ /dev/null
@@ -1,234 +0,0 @@
-
-
-
- Build file for the User Profile
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/deployment/bin/start-server.sh b/deployment/bin/start-server.sh
new file mode 100755
index 0000000..ca47f43
--- /dev/null
+++ b/deployment/bin/start-server.sh
@@ -0,0 +1,4 @@
+# this is a dummy file set with correct permissions so that when it's overwritten by
+# Dockerize the script can run.
+
+# TODO get rid of all this dockerize stuff and just use env vars for everything, like collections
\ No newline at end of file
diff --git a/deployment/conf/.templates/deployment.cfg.templ b/deployment/conf/.templates/deployment.cfg.templ
index c307da3..68d5a58 100644
--- a/deployment/conf/.templates/deployment.cfg.templ
+++ b/deployment/conf/.templates/deployment.cfg.templ
@@ -17,15 +17,12 @@ mongodb-host = {{ default .Env.mongodb_host "ci-mongo" }}
# name of the workspace mongo database
mongodb-database = {{ default .Env.mongodb_database "user_profile_db" }}
# the user name for an account with readWrite access to the database
-mongodb-user = {{ default .Env.mongodb_user "upserv" }}
+mongodb-user = {{ default .Env.mongodb_user "" }}
# password for the account
-mongodb-pwd = {{ default .Env.mongodb_pwd "fake" }}
+mongodb-pwd = {{ default .Env.mongodb_pwd "" }}
# the user name for an administrator
admin = {{ default .Env.admin "kbuserprofileadmin" }}
-# Base directory
-basedir={{ default .Env.basedir "user_profile" }}
-
auth-service-url = {{ default .Env.auth_service_url "https://ci-kbase.us/services/authorization" }}
auth-service-url-allow-insecure = {{ default .Env.auth_service_allow_insecure "false" }}
diff --git a/deployment/conf/example.ini b/deployment/conf/example.ini
index 9780d8d..00288d4 100644
--- a/deployment/conf/example.ini
+++ b/deployment/conf/example.ini
@@ -6,10 +6,8 @@ mongodb_database=user_profile_db
mongodb_user=upserv
mongodb_pwd=fake
admin=kbuserprofileadmin
-basedir=user_profile
-auth_service_url=https://ci-kbase.us/services/authorization
+auth_service_url=https://ci.kbase.us/services/auth/api/legacy/KBase/Sessions/Login
auth_service_allow_insecure=false
-globus_url=https://nexus.api.globusonline.org
port=8080
server_threads=20
max_memory=3000
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..f5cfeac
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,40 @@
+version: '3.4'
+
+services:
+ user_profile:
+ # build the nms docker image locally
+ build: .
+ # to use the latest docker image from ghcr.io
+ # uncomment the next line and comment out the build line
+ # image: ghcr.io/kbase/user_profile:latest
+ ports:
+ - "8080:8080"
+ depends_on: ["mongo"]
+ environment:
+ # see deployment/conf/.templates for more environment variables
+ - mongodb_host=mongo:27017
+ - mongodb_database=user_profile
+ - auth_service_url=https://ci.kbase.us/services/auth/api/legacy/KBase/Sessions/Login
+ - auth_service_url_allow_insecure=false
+ - port=8080
+ command:
+ - "-wait"
+ - "tcp://mongo:27017"
+ - "-timeout"
+ - "120s"
+ - "-template"
+ - "/kb/deployment/conf/.templates/deployment.cfg.templ:/kb/deployment/conf/deployment.cfg"
+ - "-template"
+ - "/kb/deployment/conf/.templates/http.ini.templ:/kb/deployment/jettybase/start.d/http.ini"
+ - "-template"
+ - "/kb/deployment/conf/.templates/server.ini.templ:/kb/deployment/jettybase/start.d/server.ini"
+ - "-template"
+ - "/kb/deployment/conf/.templates/start-server.sh.templ:/kb/deployment/bin/start-server.sh"
+ - "-stdout"
+ - "/kb/deployment/jettybase/logs/request.log"
+ - "/kb/deployment/bin/start-server.sh"
+
+ mongo:
+ image: "mongo:3.6.23"
+ ports:
+ - "27017:27017"
diff --git a/hooks/build b/hooks/build
deleted file mode 100755
index ffed924..0000000
--- a/hooks/build
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-# See the docs for automated docker builds: https://docs.docker.com/docker-cloud/builds/advanced/
-
-# $IMAGE_NAME var is injected into the build so the tag is correct.
-
-echo "Build hook running"
-export BRANCH=${TRAVIS_BRANCH:-`git symbolic-ref --short HEAD`}
-export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
-export COMMIT=${TRAVIS_COMMIT:-`git rev-parse --short HEAD`}
-docker build --build-arg BUILD_DATE=$DATE \
- --build-arg VCS_REF=$COMMIT \
- --build-arg BRANCH=$BRANCH \
- -t ${IMAGE_NAME} .
diff --git a/jettybase/webapps/ROOT.war b/jettybase/webapps/ROOT.war
deleted file mode 100644
index dcbebb6..0000000
Binary files a/jettybase/webapps/ROOT.war and /dev/null differ
diff --git a/server_scripts/build_server_control_scripts.py b/server_scripts/build_server_control_scripts.py
deleted file mode 100755
index 6175ce8..0000000
--- a/server_scripts/build_server_control_scripts.py
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/env python
-'''
-Created on Mar 11, 2014
-
-@author: gaprice@lbl.gov
-'''
-from __future__ import print_function
-import sys
-from configobj import ConfigObj
-import os
-import stat
-
-PORT = 'port'
-THREADS = 'server-threads'
-MINMEM = 'min-memory'
-MAXMEM = 'max-memory'
-
-
-def printerr(*objs):
- print(*objs, file=sys.stderr)
- sys.exit(1)
-
-
-def make_executable(path):
- st = os.stat(path)
- os.chmod(path, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
-
-
-def getConfig(param, cfg, cfile):
- if param not in cfg:
- printerr('Missing expected parameter {} in config file {}'
- .format(param, cfile))
- return cfg[param]
-
-if len(sys.argv) < 8:
- printerr("Missing arguments to build_server_control_scripts")
-if len(sys.argv) == 8:
- _, serviceDir, war, target, javaHome, deployCfg, asadmin, serviceDomain =\
- sys.argv
- port = None
-else:
- _, serviceDir, war, target, javaHome, deployCfg, asadmin, serviceDomain,\
- port = sys.argv
-
-if not os.path.isfile(deployCfg):
- printerr('Configuration parameter is not a file: ' + deployCfg)
-cfg = ConfigObj(deployCfg)
-if serviceDomain not in cfg:
- printerr('No {} section in config file {} - '.format(
- serviceDomain, deployCfg))
-wscfg = cfg[serviceDomain]
-
-if port is None:
- if PORT not in wscfg:
- printerr("Port not provided as argument or in config")
- port = wscfg[PORT]
-
-threads = getConfig(THREADS, wscfg, deployCfg)
-minmem = getConfig(MINMEM, wscfg, deployCfg)
-maxmem = getConfig(MAXMEM, wscfg, deployCfg)
-
-with open(os.path.join(serviceDir, 'start_service'), 'w') as ss:
- ss.write('export JAVA_HOME={}\n'.format(javaHome))
- ss.write('export PATH=$JAVA_HOME/bin:$PATH\n')
- ss.write(('JARS={}/lib/jars\n').format(target))
- ss.write('if [ -z "$KB_DEPLOYMENT_CONFIG" ]\n')
- ss.write('then\n')
- ss.write(' export KB_DEPLOYMENT_CONFIG={}/deployment.cfg\n'
- .format(target))
- ss.write('fi\n')
- ss.write(('cd {}\n').format(serviceDir))
- ss.write(('java -cp $JARS/jetty/jetty-start-7.0.0.jar:$JARS/jetty/jetty-all-7.0.0.jar:$JARS/servlet/servlet-api-2.5.jar ' +
- '-Xmx{}m ' +
- '-Djetty.port={} ' +
- '-DKB_DEPLOYMENT_CONFIG=$KB_DEPLOYMENT_CONFIG ' +
- 'org.eclipse.jetty.start.Main jetty.xml\n')
- .format(maxmem,port,serviceDir,serviceDir))
-
-with open(os.path.join(serviceDir, 'stop_service'), 'w') as ss:
- ss.write('export JAVA_HOME={}\n'.format(javaHome))
- ss.write('export PATH=$JAVA_HOME/bin:$PATH\n')
- ss.write('export CLASSPATH=\n')
- ss.write('killall java\n')
-
-make_executable(os.path.join(serviceDir, 'start_service'))
-make_executable(os.path.join(serviceDir, 'stop_service'))
diff --git a/server_scripts/get_deploy_cfg.pm b/server_scripts/get_deploy_cfg.pm
deleted file mode 100644
index bcded36..0000000
--- a/server_scripts/get_deploy_cfg.pm
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-use Getopt::Long;
-use Config::Simple;
-
-my $DESCRIPTION =
-"
-usage:
- get_deploy_cfg [Options] [VariableName]
-
- Retrieve the value of a variable in a KBase 'deploy.cfg' file (essentially a simple
- INI file) by variable name. The value is printed to standard out.
-
- -d, --deploy-cfg [FILE]
- (optional) the location of the deploy.cfg file to use; if not provided, the
- script assumes the file is named 'deploy.cfg' in your current working directory
-
- -h, --help
- diplay this help message, ignore all arguments
-";
-
-my $help = '';
-my $deploy_cfg_file = 'deploy.cfg';
-my $opt = GetOptions (
- "help|h" => \$help,
- "deploy-cfg|d=s" => \$deploy_cfg_file
- );
-if($help) {
- print $DESCRIPTION;
- exit 0;
-}
-
-#process args
-my $n_args = $#ARGV+1;
-if ($n_args != 1) {
- print STDERR "ERROR: Incorrect number of arguments- must specify a variable name.\n";
- print STDERR $DESCRIPTION;
- exit 1;
-}
-my $varname = $ARGV[0];
-
-#read the cfg file
-if (!-e $deploy_cfg_file) {
- print STDERR "ERROR: Cannot find deploy.cfg (looking for '$deploy_cfg_file').\n";
- print STDERR "Rerun with --help option for usage.\n";
- exit 1;
-}
-my $cfg_lookup={};
-Config::Simple->import_from($deploy_cfg_file, $cfg_lookup);
-
-if (defined $cfg_lookup->{$varname}) {
- print STDOUT $cfg_lookup->{$varname};
-} else {
- print STDERR "ERROR: Variable '$varname' not defined in config file '$deploy_cfg_file').\n";
- print STDERR " Available variables are: \n";
- if (scalar(keys(%$cfg_lookup))==0) {
- print STDERR " --no variables were found--\n";
- }
- else {
- foreach my $key (keys %$cfg_lookup) {
- print STDERR " $key\n";
- }
- }
-}
-
-exit 0;
-
-
-
-
diff --git a/server_scripts/glassfish_administer_service.py b/server_scripts/glassfish_administer_service.py
deleted file mode 100755
index f07a370..0000000
--- a/server_scripts/glassfish_administer_service.py
+++ /dev/null
@@ -1,315 +0,0 @@
-#!/usr/bin/env python
-'''
-Created on Dec 6, 2013
-
-@author: gaprice@lbl.gov
-'''
-from __future__ import print_function
-from argparse import ArgumentParser
-import subprocess
-import os
-import xml.etree.ElementTree as ET
-import urllib2
-from subprocess import CalledProcessError
-import sys
-
-_PARALLEL_GC = "-XX:-UseParallelGC"
-_PARALLEL_GC_ESC = "-XX\:-UseParallelGC"
-
-
-def _parseArgs():
- parser = ArgumentParser(description='script to administer a Glassfish ' +
- ' application.')
- parser.add_argument('-w', '--war',
- help='path to the application WAR file. If ' +
- 'omitted, the service at the port and domain is ' +
- 'stopped.')
- parser.add_argument('-a', '--admin', required=True,
- help='location of the Glassfish asadmin program.')
- parser.add_argument('-d', '--domain', required=True,
- help='name of the Glassfish domain where the ' +
- 'application is or will be installed.')
- parser.add_argument('-l', '--domain-dir',
- help='directory where the glassfish domain ' +
- 'information and logs will be stored. Defaults to ' +
- 'glassfish/domains.')
- parser.add_argument('-p', '--port', required=True, type=int,
- help='the port where the application runs.')
- parser.add_argument('-t', '--threads', type=int, default=20,
- help='the number of threads for the application.')
- parser.add_argument('-s', '--Xms', type=int,
- help='minimum memory for the domain in MB. ' +
- 'This will cause a domain restart if changed.')
- parser.add_argument('-x', '--Xmx', type=int,
- help='maximum memory for the domain in MB. ' +
- 'This will cause a domain restart if changed.')
- parser.add_argument('-r', '--properties', nargs='*',
- help='JVM system properties to add to the server.')
- parser.add_argument('-g', '--noparallelgc', action='store_true',
- help='turn off the parallel garbage ' +
- ' collector and use the standard gc.')
- return parser.parse_args()
-
-
-class CommandGlassfishDomain(object):
-
- def __init__(self, asadminpath, domain, domainpath):
- self.asadminpath = asadminpath
- self.domain = domain
- self.path = None
- if (domainpath):
- domaindir = os.path.abspath(os.path.expanduser(domainpath))
- if not os.path.isdir(domaindir):
- if not os.path.exists(domaindir):
- os.mkdir(domaindir)
- else:
- print('Domain path ' + domainpath + ' must be a directory')
- sys.exit(1)
- self.path = domaindir
- p = (' at ' + self.path) if(self.path) else ''
- if self.exists():
- print('Domain ' + self.domain + ' exists' + p +
- ', skipping creation')
- else:
- print('Creating domain ' + self.domain + p)
- print(self._run_local_command('create-domain', '--nopassword=true',
- self.domain).rstrip())
- self.adminport = self.get_admin_port()
- self.start_domain()
-
- def get_admin_port(self):
- #the fact I have to do this is moronic
- if (self.path):
- domains = self.path
- else:
- bindir = os.path.dirname(self.asadminpath)
- glassfish = os.path.join(bindir, "..")
- domains = os.path.join(glassfish, "domains")
- domain = os.path.join(domains, self.domain)
- configfile = os.path.join(domain, "config/domain.xml")
- xml = ET.parse(configfile)
- root = xml.getroot()
- config = root.findall("./configs/config[@name='server-config']")[0]
- adminlist = config.findall(
- "./network-config/network-listeners/network-listener[@protocol=" +
- "'admin-listener']")[0]
- return adminlist.attrib['port']
-
- def start_domain(self):
- if self.is_running():
- print ("Domain " + self.domain + " is already running on port " +
- self.adminport)
- else:
- print("Starting domain " + self.domain)
- print(self._run_local_command('start-domain', self.domain)
- .rstrip())
- self.adminport = self.get_admin_port()
-
- def restart_domain(self):
- if self.is_running():
- print("Restarting " + self.domain + ", please wait")
- print(self._run_local_command('restart-domain', self.domain)
- .rstrip())
- else:
- self.start_domain()
-
- def exists(self):
- return self.domain in self._list_domains()
-
- def is_running(self):
- return self.domain + " running" in self._list_domains()
-
- def start_service(self, war, port, threads):
- portstr = str(port)
- threadstr = str(threads)
- if 'server-' + portstr in self._run_remote_command(
- 'list-virtual-servers'):
- print("Virtual server already exists")
- else:
- print(self._run_remote_command(
- 'create-virtual-server', '--hosts',
- '${com.sun.aas.hostName}', 'server-' + portstr).rstrip())
- if 'thread-pool-' + portstr in self._run_remote_command(
- 'list-threadpools', 'server'):
- print("Threadpool already exists")
- else:
- print(self._run_remote_command(
- 'create-threadpool', '--maxthreadpoolsize=' + threadstr,
- '--minthreadpoolsize=' + threadstr, 'thread-pool-' + portstr)
- .rstrip())
- if 'http-listener-' + portstr in self._run_remote_command(
- 'list-http-listeners'):
- print('Http listener already exists')
- else:
- print(self._run_remote_command(
- 'create-http-listener', '--listeneraddress', '0.0.0.0',
- '--listenerport', portstr,
- '--default-virtual-server', 'server-' + portstr,
- '--securityEnabled=false', '--acceptorthreads=' + threadstr,
- 'http-listener-' + portstr).rstrip())
- print(self._run_remote_command(
- 'set', 'server.network-config.network-listeners.' +
- 'network-listener.http-listener-' + portstr +
- '.thread-pool=thread-pool-' + portstr).rstrip())
- print(self._run_remote_command(
- 'set', 'server.network-config.protocols.protocol.' +
- 'http-listener-' + portstr + '.http.timeout-seconds=1800')
- .rstrip())
- if 'app-' + portstr in self._run_remote_command('list-applications'):
- print(self._run_remote_command('undeploy', 'app-' + portstr)
- .rstrip())
- print(self._run_remote_command(
- 'deploy', '--virtualservers', 'server-' + portstr,
- '--contextroot', '/', '--name', 'app-' + portstr, war).rstrip())
- try:
- localCheckUrl = 'http://localhost:' + portstr + '/rpc'
- print('Attempting to check if rpc service is up here: '+localCheckUrl)
- urllib2.urlopen(localCheckUrl)
- except urllib2.HTTPError as h:
- resp = h.read()
- else:
- print('Unexpected response from server - the server did not ' +
- 'start up successfully. Please check the glassfish logs.')
- return False
- if '32603' in resp:
- print('The server failed to start up successfully and is ' +
- 'running in protected mode. Please check the system and ' +
- 'glassfish logs.')
- return False
- elif '32300' in resp:
- print('The server started successfully.')
- return True
- else:
- print('The server failed to start up successfully and is not '
- + 'running. Please check the system and glassfish logs.')
- return False
-
- def stop_service(self, port):
- portstr = str(port)
- if 'app-' + portstr in self._run_remote_command('list-applications'):
- print(self._run_remote_command('undeploy', 'app-' + portstr)
- .rstrip())
- if 'http-listener-' + portstr in self._run_remote_command(
- 'list-http-listeners'):
- print(self._run_remote_command(
- 'delete-http-listener', 'http-listener-' + portstr).rstrip())
- if 'http-listener-' + portstr in self._run_remote_command(
- 'list-protocols'):
- print(self._run_remote_command(
- 'delete-protocol', 'http-listener-' + portstr).rstrip())
- if 'thread-pool-' + portstr in self._run_remote_command(
- 'list-threadpools', 'server'):
- print(self._run_remote_command(
- 'delete-threadpool', 'thread-pool-' + portstr).rstrip())
- if 'server-' + portstr in self._run_remote_command(
- 'list-virtual-servers'):
- print(self._run_remote_command(
- 'delete-virtual-server', 'server-' + portstr).rstrip())
-
- def set_min_max_memory(self, minm, maxm):
- # will restart the domain if changes are necessary
- xmx = []
- xms = []
- for o in self._run_remote_command('list-jvm-options').split('\n'):
- if o.startswith('-Xmx'):
- xmx.append(o)
- if o.startswith('-Xms'):
- xms.append(o)
- if (len(xms) > 1 and minm is None):
- print('WARNING: multiple Xms parameters set on service: ' +
- str(xms))
- if (len(xmx) > 1 and maxm is None):
- print('WARNING: multiple Xmx parameters set on service: ' +
- str(xmx))
- changed = self._set_memory(None if minm is None else '-Xms' +
- str(minm) + 'm', xms)
- changed2 = self._set_memory(None if maxm is None else '-Xmx'
- + str(maxm) + 'm', xmx)
- if changed or changed2:
- self.restart_domain()
-
- def reenable_parallel_gc(self):
- if self.parallel_gc_is_disabled():
- self.delete_jvm_option(_PARALLEL_GC_ESC)
- self.restart_domain()
-
- def parallel_gc_is_disabled(self):
- for o in self._run_remote_command('list-jvm-options').split('\n'):
- if o == _PARALLEL_GC:
- return True
- return False
-
- def stop_parallel_gc(self):
- if not self.parallel_gc_is_disabled():
- self.create_jvm_option(_PARALLEL_GC_ESC)
- self.restart_domain()
-
- def create_property(self, prop):
- print('Creating property ' + prop)
- print(self._run_remote_command('create-system-properties', prop)
- .rstrip())
-
- def create_jvm_option(self, prop):
- print('Creating jvm property ' + prop)
- print(self._run_remote_command('create-jvm-options', prop)
- .rstrip())
-
- def delete_jvm_option(self, prop):
- print('Removing jvm property ' + prop)
- print(self._run_remote_command('delete-jvm-options', prop).rstrip())
-
- def _set_memory(self, memstr, memlist):
- if (memstr is not None and [memstr] != memlist):
- print("Removing options " + str(memlist))
- for o in memlist:
- self._remove_option(o)
- print("Setting option " + memstr)
- self._set_option(memstr)
- return True
- else:
- return False
-
- def _set_option(self, opt):
- self._run_remote_command('create-jvm-options', opt)
-
- def _remove_option(self, opt):
- self._run_remote_command('delete-jvm-options', opt)
-
- def _list_domains(self):
- return self._run_local_command('list-domains')
-
- def _run_local_command(self, subcmd, *args):
- cmd = [self.asadminpath, subcmd]
- if (self.path):
- cmd.extend(['--domaindir', self.path])
- try:
- return subprocess.check_output(cmd + list(args))
- except CalledProcessError as cpe:
- print(cpe.output.rstrip())
- sys.exit(1)
-
- def _run_remote_command(self, *cmd):
- try:
- return subprocess.check_output([self.asadminpath, '-p',
- self.adminport] + list(cmd))
- except CalledProcessError as cpe:
- print(cpe.output.rstrip())
- sys.exit(1)
-
-
-if __name__ == '__main__':
- args = _parseArgs()
- gf = CommandGlassfishDomain(args.admin, args.domain, args.domain_dir)
- if (args.war == None):
- gf.stop_service(args.port)
- else:
- if (args.noparallelgc):
- gf.stop_parallel_gc()
- else:
- gf.reenable_parallel_gc()
- gf.set_min_max_memory(args.Xms, args.Xmx)
- for p in args.properties:
- gf.create_property(p)
- success = gf.start_service(args.war, args.port, args.threads)
- if not success:
- sys.exit(1)
diff --git a/server_scripts/jetty.xml b/server_scripts/jetty.xml
deleted file mode 100644
index ff58d23..0000000
--- a/server_scripts/jetty.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- 5
- 200
-
-
-
-
-
-
- 0.0.0.0
-
- 1800000
- 2
- false
-
- 10000
- 5000
-
-
-
-
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
-
-
-
-
- /webapps/root.war
- /
-
-
- - org.eclipse.jetty.webapp.WebInfConfiguration
- - org.eclipse.jetty.webapp.WebXmlConfiguration
- - org.eclipse.jetty.webapp.MetaInfConfiguration
- - org.eclipse.jetty.webapp.JettyWebXmlConfiguration
- - org.eclipse.jetty.webapp.TagLibConfiguration
-
-
- /temp/
- true
- true
- false
-
- org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern
- .*/.*jsp-api-[^/]*\.jar$|.*/.*jsp-[^/]*\.jar$|.*/.*taglibs[^/]*\.jar$
-
-
-
- [
-
-
- ./yyyy_mm_dd.request.log
- yyyy_MM_dd
- 90
- true
- false
- false
- GMT
-
-
- ]
-
- true
- true
- true
- 1000
-
-
diff --git a/src/main/java/us/kbase/userprofile/UserProfileServer.java b/src/main/java/us/kbase/userprofile/UserProfileServer.java
index dc7a74e..9a80b92 100644
--- a/src/main/java/us/kbase/userprofile/UserProfileServer.java
+++ b/src/main/java/us/kbase/userprofile/UserProfileServer.java
@@ -28,7 +28,7 @@ public class UserProfileServer extends JsonServerServlet {
private static final String gitCommitHash = "8a56e04b45d01c27c45c65dd80f62c5b4dde885c";
//BEGIN_CLASS_HEADER
- public static final String VERSION = "0.2.2";
+ public static final String VERSION = "0.3.0";
public static final String SYS_PROP_KB_DEPLOYMENT_CONFIG = "KB_DEPLOYMENT_CONFIG";
public static final String SERVICE_DEPLOYMENT_NAME = "UserProfile";
@@ -38,9 +38,6 @@ public class UserProfileServer extends JsonServerServlet {
public static final String CFG_MONGO_USER = "mongodb-user";
public static final String CFG_MONGO_PSWD = "mongodb-pwd";
public static final String CFG_ADMIN = "admin";
- public static final String CFG_PROP_AUTH_SERVICE_URL = "auth-service-url";
- public static final String CFG_PROP_GLOBUS_URL = "globus-url";
- public static final String CFG_PROP_AUTH_INSECURE = "auth-service-url-allow-insecure";
private static Throwable configError = null;
private static Map config = null;
@@ -71,13 +68,12 @@ public static Map config() {
}
private String getConfig(String configName) {
String ret = config().get(configName);
- if (ret == null)
+ if (ret == null || ret.trim().isEmpty())
throw new IllegalStateException("Parameter " + configName + " is not defined in configuration");
return ret;
}
private final MongoController db;
- private final boolean authAllowInsecure;
//END_CLASS_HEADER
public UserProfileServer() throws Exception {
@@ -88,12 +84,6 @@ public UserProfileServer() throws Exception {
System.out.println(UserProfileServer.class.getName() + ": " + CFG_MONGO_DB +" = " + getConfig(CFG_MONGO_DB));
System.out.println(UserProfileServer.class.getName() + ": " + CFG_ADMIN +" = " + getConfig(CFG_ADMIN));
- String authAllowInsecureString = config().get(CFG_PROP_AUTH_INSECURE);
- System.out.print(UserProfileServer.class.getName() + ": " + CFG_PROP_AUTH_INSECURE +" = " +
- (authAllowInsecureString == null ? "" : authAllowInsecureString));
- this.authAllowInsecure = "true".equals(authAllowInsecureString);
- System.out.println(" [flag interpreted to be:"+this.authAllowInsecure + "]");
-
String mongoUser = ""; boolean useMongoAuth = true;
try{
mongoUser = getConfig(CFG_MONGO_USER);
diff --git a/src/test/java/us/kbase/test/userprofile/FullServerTest.java b/src/test/java/us/kbase/test/userprofile/FullServerTest.java
index 65737ad..211d778 100644
--- a/src/test/java/us/kbase/test/userprofile/FullServerTest.java
+++ b/src/test/java/us/kbase/test/userprofile/FullServerTest.java
@@ -203,8 +203,8 @@ public static void setUpClass() throws Exception {
ws.add(UserProfileServer.CFG_MONGO_HOST, "localhost:" + MONGO.getServerPort());
ws.add(UserProfileServer.CFG_MONGO_DB , "user_profile_test");
ws.add(UserProfileServer.CFG_ADMIN, adminAuthToken.getUserName());
- ws.add(UserProfileServer.CFG_PROP_AUTH_SERVICE_URL, authServiceUrl);
- ws.add(UserProfileServer.CFG_PROP_AUTH_INSECURE, authAllowInsecureString);
+ ws.add("auth-service-url", authServiceUrl);
+ ws.add("auth-service-url-allow-insecure", authAllowInsecureString);
ini.store(iniFile);
iniFile.deleteOnExit();