-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
149 lines (122 loc) · 5.05 KB
/
Makefile
File metadata and controls
149 lines (122 loc) · 5.05 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
TOP_DIR = ../..
include $(TOP_DIR)/tools/Makefile.common
TARGET ?= /kb/deployment
DEPLOY_TARGET ?= $(TARGET)
DEPLOY_RUNTIME ?= /kb/runtime
SERVER_SPEC = Workspace.spec
SERVICE_MODULE = lib/Bio/P3/Workspace/Service.pm
SERVICE = Workspace
SERVICE_PORT = 7125
DOWNLOAD_SERVICE = WorkspaceDownload
DOWNLOAD_SERVICE_PORT = 7129
COMPLETION_SERVICE = WorkspaceCompletion
COMPLETION_SERVICE_PORT = 7140
SERVICE_URL = https://p3.theseed.org/services/$(SERVICE)
DOWNLOAD_URL = https://p3.theseed.org/services/$(DOWNLOAD_SERVICE)
COMPLETION_URL = https://p3.theseed.org/services/$(COMPLETION_SERVICE)
SERVICE_NAME = Workspace
SERVICE_NAME_PY = $(SERVICE_NAME)
DOWNLOAD_SERVICE_NAME = WorkspaceDownload
COMPLETION_SERVICE_NAME = WorkspaceCompletion
SERVICE_PSGI_FILE = $(SERVICE_NAME).psgi
DOWNLOAD_SERVICE_PSGI_FILE = $(DOWNLOAD_SERVICE_NAME).psgi
COMPLETION_SERVICE_PSGI_FILE = $(COMPLETION_SERVICE_NAME).psgi
SRC_SERVICE_PERL = $(wildcard service-scripts/*.pl) $(wildcard internal-scripts/*.pl)
BIN_SERVICE_PERL = $(addprefix $(BIN_DIR)/,$(basename $(notdir $(SRC_SERVICE_PERL))))
DEPLOY_SERVICE_PERL = $(addprefix $(SERVICE_DIR)/bin/,$(basename $(notdir $(SRC_SERVICE_PERL))))
ifdef TEMPDIR
TPAGE_TEMPDIR = --define kb_tempdir=$(TEMPDIR)
endif
ifdef DEPLOYMENT_VAR_DIR
SERVICE_LOGDIR = $(DEPLOYMENT_VAR_DIR)/services/$(SERVICE)
TPAGE_SERVICE_LOGDIR = --define kb_service_log_dir=$(SERVICE_LOGDIR)
endif
TPAGE_DEPLOY_ARGS = \
--define kb_top=$(DEPLOY_TARGET) \
--define kb_runtime=$(DEPLOY_RUNTIME)
TPAGE_BUILD_ARGS = \
--define kb_top=$(TARGET) \
--define kb_runtime=$(DEPLOY_RUNTIME)
TPAGE_ARGS = \
--define kb_service_name=$(SERVICE) \
--define kb_service_port=$(SERVICE_PORT) \
--define kb_psgi=$(SERVICE_PSGI_FILE) \
--define kb_download_port=$(DOWNLOAD_SERVICE_PORT) \
--define kb_download_psgi=$(DOWNLOAD_SERVICE_PSGI_FILE) \
--define kb_completion_port=$(COMPLETION_SERVICE_PORT) \
--define kb_completion_psgi=$(COMPLETION_SERVICE_PSGI_FILE) \
--define kb_starman_workers=25 \
$(TPAGE_TEMPDIR) \
$(TPAGE_SERVICE_LOGDIR)
TESTS = $(wildcard t/client-tests/*.t)
all: bin compile-typespec service
jarfile:
gen_java_client $(SERVER_SPEC) org.patricbrc.Workspace java
javac java/org/patricbrc/Workspace/*java
cd java; jar cf ../Workspace.jar org/patricbrc/Workspace/*.class
test:
# run each test
echo "RUNTIME=$(DEPLOY_RUNTIME)\n"
for t in $(TESTS) ; do \
if [ -f $$t ] ; then \
$(DEPLOY_RUNTIME)/bin/perl $$t ; \
if [ $$? -ne 0 ] ; then \
exit 1 ; \
fi \
fi \
done
service: $(SERVICE_MODULE)
compile-typespec: Makefile
mkdir -p lib/biop3/$(SERVICE_NAME_PY)
touch lib/biop3/__init__.py #do not include code in biop3/__init__.py
touch lib/biop3/$(SERVICE_NAME_PY)/__init__.py
mkdir -p lib/javascript/$(SERVICE_NAME)
compile_typespec \
--patric \
--psgi $(SERVICE_PSGI_FILE) \
--impl Bio::P3::$(SERVICE_NAME)::$(SERVICE_NAME)Impl \
--service Bio::P3::$(SERVICE_NAME)::Service \
--client Bio::P3::$(SERVICE_NAME)::$(SERVICE_NAME)Client \
--py biop3/$(SERVICE_NAME_PY)/$(SERVICE_NAME)Client \
--js javascript/$(SERVICE_NAME)/$(SERVICE_NAME)Client \
--url $(SERVICE_URL) \
$(SERVER_SPEC) lib
-rm -f lib/$(SERVER_MODULE)Server.py
-rm -f lib/$(SERVER_MODULE)Impl.py
bin: $(BIN_PERL) $(BIN_SERVICE_PERL)
deploy: deploy-client deploy-service
deploy-all: deploy-client deploy-service
deploy-client: compile-typespec deploy-docs deploy-libs deploy-scripts
deploy-service: deploy-dir deploy-monit deploy-libs deploy-service-scripts-local
$(TPAGE) $(TPAGE_DEPLOY_ARGS) $(TPAGE_ARGS) service/start_service.tt > $(TARGET)/services/$(SERVICE)/start_service
chmod +x $(TARGET)/services/$(SERVICE)/start_service
$(TPAGE) $(TPAGE_DEPLOY_ARGS) $(TPAGE_ARGS) service/stop_service.tt > $(TARGET)/services/$(SERVICE)/stop_service
chmod +x $(TARGET)/services/$(SERVICE)/stop_service
deploy-service-scripts-local:
export KB_TOP=$(DEPLOY_TARGET); \
export KB_RUNTIME=$(DEPLOY_RUNTIME); \
export KB_PERL_PATH=$(TARGET)/lib ; \
export PATH_PREFIX=$(DEPLOY_TARGET)/services/$(SERVICE)/bin:$(DEPLOY_TARGET)/services/cdmi_api/bin; \
for src in $(SRC_SERVICE_PERL) ; do \
basefile=`basename $$src`; \
base=`basename $$src .pl`; \
echo install $$src $$base ; \
cp $$src $(TARGET)/plbin ; \
$(WRAP_PERL_SCRIPT) "$(TARGET)/plbin/$$basefile" $(TARGET)/services/$(SERVICE)/bin/$$base ; \
done
deploy-monit:
$(TPAGE) $(TPAGE_DEPLOY_ARGS) $(TPAGE_ARGS) service/process.$(SERVICE).tt > $(TARGET)/services/$(SERVICE)/process.$(SERVICE)
deploy-docs:
-mkdir doc
-mkdir $(SERVICE_DIR)
-mkdir $(SERVICE_DIR)/webroot
mkdir -p doc
$(DEPLOY_RUNTIME)/bin/pod2html -t "Workspace API" lib/Bio/P3/Workspace/WorkspaceImpl.pm > doc/workspace_impl.html
cp doc/*html $(SERVICE_DIR)/webroot/.
deploy-dir:
if [ ! -d $(SERVICE_DIR) ] ; then mkdir $(SERVICE_DIR) ; fi
if [ ! -d $(SERVICE_DIR)/webroot ] ; then mkdir $(SERVICE_DIR)/webroot ; fi
if [ ! -d $(SERVICE_DIR)/bin ] ; then mkdir $(SERVICE_DIR)/bin ; fi
$(BIN_DIR)/%: internal-scripts/%.pl $(TOP_DIR)/user-env.sh
$(WRAP_PERL_SCRIPT) '$$KB_TOP/modules/$(CURRENT_DIR)/$<' $@
include $(TOP_DIR)/tools/Makefile.common.rules