Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.{ File, FileWriter }
- import scala.sys.process.Process
- object Main {
- val MEX_HOME = "/home/itang/mex/workspace/mex-front-side"
- val JAR_FILE = MEX_HOME + "/target/tdb-0.1.0-SNAPSHOT.jar"
- val TARGET_DIR = "/tmp/mex_scala"
- val TARGET_LIB_DIR = TARGET_DIR + "/lib"
- implicit class sw(s: String) {
- def exec() = Process(s.split("\\s").toList, new File(MEX_HOME)).!!
- def writeTo(file: File) = {
- val writer = new FileWriter(file)
- writer.write(s)
- writer.close()
- }
- }
- def main(args: Array[String]): Unit = {
- prepare()
- taskJar()
- taskCopyLibs()
- taskRunShell()
- System.exit(0)
- }
- def prepare(): Unit = {
- s"rm -rf $TARGET_DIR".exec
- s"mkdir -p $TARGET_LIB_DIR".exec
- }
- def taskJar(): Unit = {
- s"lein jar".exec
- s"cp $JAR_FILE $TARGET_LIB_DIR".exec
- }
- def taskCopyLibs(): Unit = {
- val cps: String = s"lein with-profile uberjar classpath".exec
- for (jar ← cps.split(":").filter(_.endsWith(".jar"))) {
- s"cp $jar $TARGET_LIB_DIR".exec
- }
- }
- def taskRunShell() = {
- val cps = new File(TARGET_LIB_DIR).listFiles().map(_.getAbsolutePath).toList.mkString(":")
- val content = s"""#!/bin/bash
- export RUN_MODE=prod
- export DATA_DIR=./data
- CLASSPATH=${cps}
- nohup java -Xms1g -Xmx2g -Xss1M -XX:MaxPermSize=392m -cp $$CLASSPATH clojure.main -m app.core &
- """
- content writeTo new File(TARGET_DIR, "run.sh")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement