Mercurial > rlm
comparison src/rlm/clj.clj @ 0:78a630e650d2
initial import
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 18 Oct 2011 00:57:08 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:78a630e650d2 |
---|---|
1 #!/home/r/roBin/env-cool java -cp /home/r/roBin/libs/*:/home/r/roBin/src:/home/r/roBin/rlm-lib/* -Xms1g -Xmx1g clojure.main | |
2 | |
3 (ns rlm.clj | |
4 (:use [clojure.contrib | |
5 [duck-streams :only [file-str] ] | |
6 command-line str-utils shell-out | |
7 [seq :only [indexed]]] | |
8 [rlm shell-write])) | |
9 | |
10 (defn clj [& args] | |
11 (with-command-line args | |
12 "Simple Clojure shebang (#!) lines" | |
13 [[classpath c "java classpath in which this script will run. rlm is always on the classpath." | |
14 "/home/r/roBin/libs/*:/home/r/roBin/rlm-lib/*:/home/r/roBin/src"] | |
15 [memory m "how much memory should this stupid jvm be provided? (megabytes)" 1000] | |
16 [garbage g "level of congestion after which the jvm starts garbage collecting (megabytes)" | |
17 "30% of whatever memory is"] | |
18 [libraries l "link in libraries under -Djava.library.path" ""] | |
19 [configure conf "use a file with configureations to defeat shebang line limit don't double define things:) " "/dev/null"] | |
20 target-files] | |
21 | |
22 (if (not (= configure "/dev/null")) | |
23 (apply clj (into (re-split #" " (chomp (slurp configure))) target-files)) | |
24 | |
25 (let [ | |
26 adjusted-garbage | |
27 (if (string? garbage) | |
28 (int (* 0.3 (Integer. memory))) | |
29 garbage)] | |
30 | |
31 ;assemble arguments to be passed to java | |
32 (let [java-args | |
33 (into | |
34 ["-cp" classpath | |
35 (str "-Xmn" adjusted-garbage "M") | |
36 (str "-Xmx" memory "M") | |
37 (str "-Xms" memory "M") | |
38 (str "-Djava.library.path=\"" libraries "\"") | |
39 "clojure.main"] | |
40 target-files)] | |
41 (let [command (str "java " (str-join " " java-args))] | |
42 (println command) | |
43 (sw command) | |
44 )))))) | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 (if *command-line-args* | |
51 (let [options #{"-c" "-g" "-m" "-l" "-conf"} | |
52 fuck (split-with (fn [[index element]] (or (odd? index) (options element))) | |
53 (indexed *command-line-args*)) | |
54 fuck2 (conj (apply vector (map last (first fuck))) (str-join " " (map last (last fuck)))) | |
55 ] | |
56 (apply clj fuck2))) | |
57 | |
58 |