forked from kbase/workspace_deluxe
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
132 lines (105 loc) · 3.95 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#port is now set in deploy.cfg
SERVICE = workspace
SERVICE_CAPS = Workspace
CLIENT_JAR = WorkspaceClient.jar
WAR = WorkspaceService.war
URL = https://kbase.us/services/ws/
#End of user defined variables
TARGET ?= /kb/deployment
GITCOMMIT := $(shell git rev-parse --short HEAD)
#TODO use --points-at when git 1.7.10 available
TAGS := $(shell git tag --contains $(GITCOMMIT))
DEPLOY_RUNTIME ?= /kb/runtime
JAVA_HOME ?= $(DEPLOY_RUNTIME)/java
SERVICE_DIR ?= $(TARGET)/services/$(SERVICE)
GLASSFISH_HOME ?= $(DEPLOY_RUNTIME)/glassfish3
SERVICE_USER ?= kbase
ASADMIN = $(GLASSFISH_HOME)/glassfish/bin/asadmin
ANT = ant
# make sure our make test works
.PHONY : test
default: build-libs build-docs
build-libs:
@#TODO at some point make dependent on compile - checked in for now.
$(ANT) compile
build-docs:
-rm -r docs
$(ANT) javadoc
pod2html --infile=lib/Bio/KBase/$(SERVICE)/Client.pm --outfile=docs/$(SERVICE)_perl.html
rm -f pod2htm?.tmp
sphinx-build docsource/ docs
cp $(SERVICE).spec docs/.
cp docshtml/* docs/.
docker_deps: build-libs build-docs
$(ANT) buildwar
# cp server_scripts/glassfish_administer_service.py deployment/bin
# chmod 755 deployment/bin/glassfish_administer_service.py
mkdir -p deployment/services/workspace/
cp dist/$(WAR) deployment/services/workspace/
compile: compile-typespec compile-typespec-java compile-html
compile-html:
kb-sdk compile --html --out docshtml $(SERVICE).spec
compile-typespec-java:
kb-sdk compile --java --javasrc src --javasrv --out . \
--url $(URL) $(SERVICE).spec
compile-typespec:
kb-sdk compile \
--out lib \
--jsclname javascript/$(SERVICE)/Client \
--plclname Bio::KBase::$(SERVICE)::Client \
--pyclname biokbase.$(SERVICE).client \
--url $(URL) \
$(SERVICE).spec
rm lib/biokbase/workspace/authclient.py
test: test-service
test-service:
$(ANT) test
test-quick:
$(ANT) test_quick
deploy: deploy-client deploy-service
deploy-client: deploy-client-libs deploy-docs
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-service-libs:
$(ANT) buildwar
mkdir -p $(SERVICE_DIR)
cp dist/$(WAR) $(SERVICE_DIR)
echo $(GITCOMMIT) > $(SERVICE_DIR)/$(SERVICE).serverdist
echo $(TAGS) >> $(SERVICE_DIR)/$(SERVICE).serverdist
deploy-service-scripts:
cp server_scripts/glassfish_administer_service.py $(SERVICE_DIR)
server_scripts/build_server_control_scripts.py $(SERVICE_DIR) $(WAR)\
$(TARGET) $(JAVA_HOME) deploy.cfg $(ASADMIN) $(SERVICE_CAPS)
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] and started shock" >> /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
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
-rm -rf deployment/services/workspace/*
@#TODO remove lib once files are generated on the fly