Permalink
Browse files

lein-bin based deployment with lowmem and project version as jvm opts

  • Loading branch information...
1 parent c7ed822 commit f6646dc64f08d56e1d7d696678c4c865cdcbc04f Sridhar Ratnakumar committed Nov 16, 2011
Showing with 44 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +4 −2 CHANGES.md
  3. +3 −0 project.clj
  4. +36 −0 src/leiningen/bin.clj
View
@@ -11,3 +11,4 @@ resources/public/cljs/clojure
resources/public/cljs/horizon
.sass-cache
tmp
+horizon-*
View
@@ -1,8 +1,10 @@
# Horizon changes
-# dev
+# 1.0.0-beta5 (dev)
-* fix #4 - cloud events are not updating at all
+* fix #4 - cloud events not updating (regression in beta4)
+* lein-bin deployment: fixes missing horizon version in footer
+* reduce RSS to ~120M via JVM options (project.clj)
# 1.0.0-beta4
View
@@ -13,6 +13,9 @@
[compojure "0.6.4"]
[ring "0.3.11"]]
+ ;; reduce RSS for an acceptable run in uCloud VMs
+ :jvm-opts ["-Xmx16m" "-XX:MaxPermSize=64m" "-XX:+CMSClassUnloadingEnabled"]
+
;; websockets won't work on ring-server
:dev-dependencies [[lein-ring "0.4.5"]]
:ring {:handler horizon.web/app-routes
View
@@ -0,0 +1,36 @@
+;; Private copy of Raynes' lein-bin plugin
+
+(ns leiningen.bin
+ "Create a standalone executable for your project."
+ (:use [clojure.java.io :only [copy file]]
+ [leiningen.jar :only [get-default-uberjar-name]]
+ [leiningen.uberjar :only [uberjar]])
+ (:import java.io.FileOutputStream))
+
+(defn- jvm-options
+ "Return final JVM options for the project"
+ [project]
+ (clojure.string/join
+ " "
+ (flatten [(:jvm-opts project)
+ (format "-D%s.version=%s"
+ (:name project) (:version project))])))
+
+(defn ^{:help-arglists '([])} bin
+ "Create a standalone console executable for your project.
+
+Add :main to your project.clj to specify the namespace that contains your
+-main function."
+ [project]
+ (if (:main project)
+ (let [opts (jvm-options project)
+ target (file (:target-dir project))
+ binfile (file target (str (:name project) "-" (:version project)))]
+ (uberjar project)
+ (println "Creating standalone executable:" (.getPath binfile))
+ (with-open [bin (FileOutputStream. binfile)]
+ (.write bin (.getBytes (format ":;exec java %s -jar $0 \"$@\"\n" opts)))
+ (.write bin (.getBytes (format "@echo off\r\njava %s -jar %%1 \"%%~f0\" %%*\r\ngoto :eof\r\n" opts)))
+ (copy (file target (get-default-uberjar-name project)) bin))
+ (.setExecutable binfile true))
+ (println "Cannot create bin without :main namespace in project.clj")))

0 comments on commit f6646dc

Please sign in to comment.