aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/resources/profile.json11
-rw-r--r--src/main/scala/com/ibm/ToreeClient.scala30
2 files changed, 27 insertions, 14 deletions
diff --git a/src/main/resources/profile.json b/src/main/resources/profile.json
new file mode 100644
index 0000000..19308cc
--- /dev/null
+++ b/src/main/resources/profile.json
@@ -0,0 +1,11 @@
+{
+ "stdin_port": 48601,
+ "control_port": 48602,
+ "hb_port": 48605,
+ "shell_port": 48603,
+ "iopub_port": 48604,
+ "ip": "9.125.72.72",
+ "transport": "tcp",
+ "signature_scheme": "hmac-sha256",
+ "key": ""
+} \ No newline at end of file
diff --git a/src/main/scala/com/ibm/ToreeClient.scala b/src/main/scala/com/ibm/ToreeClient.scala
index b644b02..4da2ca5 100644
--- a/src/main/scala/com/ibm/ToreeClient.scala
+++ b/src/main/scala/com/ibm/ToreeClient.scala
@@ -31,22 +31,24 @@ class ToreeGateway(client: SparkKernelClient) {
object ToreeClient extends App {
- val profileJSON: String = """
-{
- "stdin_port": 48691,
- "control_port": 44808,
- "hb_port": 49691,
- "shell_port": 40544,
- "iopub_port": 43462,
- "ip": "9.125.72.72",
- "transport": "tcp",
- "signature_scheme": "hmac-sha256",
- "key": ""
-}
-""".stripMargin
+
+ def getConfigurationFilePath: String = {
+ var filePath = "/opt/toree_proxy/conf/profile.json"
+
+ if (args.length == 0) {
+ for (arg <- args) {
+ if (arg.contains("json")) {
+ filePath = arg
+ }
+ }
+ }
+
+ filePath
+ }
// Parse our configuration and create a client connecting to our kernel
- val config: Config = ConfigFactory.parseString(profileJSON)
+ val configFileContent = scala.io.Source.fromFile(getConfigurationFilePath).mkString
+ val config: Config = ConfigFactory.parseString(configFileContent)
val client = (new ClientBootstrap(config)
with StandardSystemInitialization