-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·104 lines (84 loc) · 3.22 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
##
# Project name - used to set the jar's file name
##
PROJ_NAME := r3z
HOST_NAME := inmra.com
HOST_USER := opc
WEB_ENGINE_JAR := r3z.jar
MINUM_LIB := lib/$(WEB_ENGINE_JAR)
VERSION=1.0.0
OUT_DIR=build
##
# default target(s)
##
all:: help
#: clean up any output files
clean::
./gradlew clean
#: jar up the application (See Java's jar command)
jar::
./gradlew jar
# This command is necessary for sending the data up to the cloud for production
#: put the jar and all scripts necessary for remote running into a tar file
bundle:: jar
mkdir -p $(OUT_DIR)/$(PROJ_NAME)
cp docs/operations/* $(OUT_DIR)/$(PROJ_NAME)
cp $(OUT_DIR)/libs/$(PROJ_NAME).jar $(OUT_DIR)/$(PROJ_NAME)
git log --oneline|head -1 > $(OUT_DIR)/$(PROJ_NAME)/code_status.txt && git diff >> $(OUT_DIR)/$(PROJ_NAME)/code_status.txt
cd $(OUT_DIR)/$(PROJ_NAME) && tar -czf "../r3z.tar.gz" *
#: send to the cloud but don't run. Depends on tests passing.
deliver:: bundle
scp -r $(OUT_DIR)/r3z.tar.gz $(HOST_USER)@$(HOST_NAME):~/
# This command does a lot. It runs a command on the production server to create a new directory, inmra, which
# won't fail if it does exist, then it un-tars our files into that directory, and then it restarts that system.
#: run the software in the cloud. Depends on deliver.
deploy:: deliver
ssh $(HOST_USER)@$(HOST_NAME) "mkdir -p r3z &&\
tar zxf r3z.tar.gz -C r3z && \
rm r3z.tar.gz && \
cd r3z &&\
sudo systemctl restart r3z.service"
JMX_PROPERTIES=-Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
DEBUG_PROPERTIES=-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=y
# This command includes several system properties so that we can connect to the
# running Java Virtual Machine with Java Mission Control (JMC)
#: run the application
run:: classes copyresources
./gradlew run
#: run the application using the jar
runjar:: jar
$(JAVA) $(JMX_PROPERTIES) -jar $(OUT_DIR)/$(PROJ_NAME).jar
#: run the tests
test:: classes copyresources testclasses
./gradlew test
#: download the production database to this directory as db.tar.gz
prod_db_download::
@echo "create a compressed tar of the database"
ssh [email protected] "cd r3z && tar zcf db.tar.gz db"
@echo "download that tar"
scp [email protected]:~/r3z/db.tar.gz ./
@echo "remove the compressed tar from the server"
ssh [email protected] "rm r3z/db.tar.gz"
# a handy debugging tool. If you want to see the value of any
# variable in this file, run something like this from the
# command line:
#
# make print-CLS
#
# and you'll get something like: CLS = out/inmra.logging/ILogger.class out/inmra.logging/Logger.class out/inmra.testing/Main.class out/inmra.utils/ActionQueue.class
print-%::
@echo $* = $($*)
# This is a handy helper. This prints a menu of items
# from this file - just put hash+colon over a target and type
# the description of that target. Run this from the command
# line with "make help"
help::
@echo
@echo Help
@echo ----
@echo
@grep -B1 -E "^[a-zA-Z0-9_-]+:([^\=]|$$)" Makefile \
| grep -v -- -- \
| sed 'N;s/\n/###/' \
| sed -n 's/^#: \(.*\)###\(.*\):.*/\2###\1/p' \
| column -t -s '###'