forked from hazelcast/hazelcast-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_rc.py
107 lines (81 loc) · 3.05 KB
/
start_rc.py
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
import os
import subprocess
import sys
from os.path import isfile
SERVER_VERSION = "5.5.0"
RC_VERSION = "0.8-SNAPSHOT"
RELEASE_REPO = "https://repo1.maven.apache.org/maven2"
ENTERPRISE_RELEASE_REPO = "https://repository.hazelcast.com/release/"
SNAPSHOT_REPO = "https://repository.hazelcast.com/snapshot-internal/"
ENTERPRISE_SNAPSHOT_REPO = "https://repository.hazelcast.com/snapshot/"
RC_REPO = "https://oss.sonatype.org/content/repositories/snapshots"
HAZELCAST_GROUP = "com.hazelcast"
if SERVER_VERSION.endswith("-SNAPSHOT"):
REPO = SNAPSHOT_REPO
ENTERPRISE_REPO = ENTERPRISE_SNAPSHOT_REPO
else:
REPO = RELEASE_REPO
ENTERPRISE_REPO = ENTERPRISE_RELEASE_REPO
IS_ON_WINDOWS = os.name == "nt"
CLASS_PATH_SEPARATOR = ";" if IS_ON_WINDOWS else ":"
def download_if_necessary(repo, group, artifact_id, version, is_test_artifact=False):
dest_file_name = artifact_id + "-" + version
if is_test_artifact:
dest_file_name += "-tests"
dest_file_name += ".jar"
if isfile(dest_file_name):
print("Not downloading %s, because it already exists." % dest_file_name)
return dest_file_name
print("Downloading " + dest_file_name)
artifact = ":".join([group, artifact_id, version])
if is_test_artifact:
artifact += ":jar:tests"
args = [
"mvn",
"-X",
"org.apache.maven.plugins:maven-dependency-plugin:2.10:get",
"-Dtransitive=false",
"-DremoteRepositories=" + repo,
"-Dartifact=" + artifact,
"-Ddest=" + dest_file_name,
"--settings=settings.xml",
]
print("Maven Args:", args)
process = subprocess.run(args, shell=IS_ON_WINDOWS)
if process.returncode != 0:
print("Failed to download " + dest_file_name)
sys.exit(1)
return dest_file_name
def start_rc(stdout=None, stderr=None):
artifacts = []
rc = download_if_necessary(RC_REPO, HAZELCAST_GROUP, "hazelcast-remote-controller", RC_VERSION)
tests = download_if_necessary(REPO, HAZELCAST_GROUP, "hazelcast", SERVER_VERSION, True)
sql = download_if_necessary(REPO, HAZELCAST_GROUP, "hazelcast-sql", SERVER_VERSION)
artifacts.extend([rc, tests, sql])
enterprise_key = os.environ.get("HAZELCAST_ENTERPRISE_KEY", None)
if enterprise_key:
server = download_if_necessary(
ENTERPRISE_REPO, HAZELCAST_GROUP, "hazelcast-enterprise", SERVER_VERSION
)
else:
server = download_if_necessary(REPO, HAZELCAST_GROUP, "hazelcast", SERVER_VERSION)
artifacts.append(server)
class_path = CLASS_PATH_SEPARATOR.join(artifacts)
args = [
"java",
"-cp",
class_path,
"com.hazelcast.remotecontroller.Main",
"--use-simple-server",
]
if enterprise_key:
args.insert(1, "-Dhazelcast.enterprise.license.key=" + enterprise_key)
return subprocess.Popen(args=args, stdout=stdout, stderr=stderr, shell=IS_ON_WINDOWS)
if __name__ == "__main__":
rc_process = start_rc()
try:
rc_process.wait()
except:
rc_process.kill()
rc_process.wait()
raise