问题描述
不管怎么说,我认为对于 shell脚本使用 clojure
会更好,但启动时间大约900ms慢。然后,我会为nailgun clojure执行 ,但显示的唯一结果是特殊情况vimclojure。这是当我,假装没有时间,转向更多 awk
ward语言启动更快。
,如何使用 nailgun
加快clojure的启动时间?
Debian
执行以下操作一次:
code> apt-get install nailgun#install nailgun
java -server -jar /usr/share/java/nailgun.jar& #run nailgun server
ng-nailgun ng-cp /usr/share/java/clojure-1.4.jar#add clj to classpath
现在服务器正在运行和配置,你可以运行你的clojure脚本:
ng-nailgun clojure.main path / to / myscript.clj
让运行实际脚本更方便,创建一个可执行文件 ng-clojure
包含以下行,并将其放在路径中的某处: ng-nailgun clojure.main$ @
在您的 clojure shell脚本,将此添加为第一行:
#!/ usr / bin / env ng-clojure
然后使clojure shell脚本可执行,并像
一样运行 path / to / myscript.clj
OSX
brew install nailgun
ng-server
ng ng-cp〜/。 m2 / repository / org / clojure / clojure / 1.5.1 / clojure-1.5.1.jar
然后执行上面的脚本。
更新:使用了一段时间后,它似乎无法正常工作。有时,我遇到的随机错误在没有钉枪的情况下不会发生,有时似乎有一个内存泄漏,使得nailgun JVM随时间消耗所有内存,最终使系统交换到磁盘。没有内存剖析这个,但想添加这个单元格。
Every now and then I think it would be nice to use clojure
for shell scripts, but a startup time of about 900ms is way too slow. I'd then startpage for "nailgun clojure", but the only results that show up are for special cases like vimclojure. That's when I, pretending not to have time, turn to more awk
ward languages that start up faster.
So, how can nailgun
be used to speed up the startup time of clojure?
Debian
Do the following once:
apt-get install nailgun # install nailgun
java -server -jar /usr/share/java/nailgun.jar& # run nailgun server
ng-nailgun ng-cp /usr/share/java/clojure-1.4.jar # add clj to classpath
Now that the server is running and configured, you can run your clojure scripts on it:
ng-nailgun clojure.main path/to/myscript.clj
In my case, startup time of the actual script went down to 80ms, compared to 900ms without nailgun.
To make running the actual script more convenient, create an executable file ng-clojure
containing the following line, and put it somewhere in your path:
ng-nailgun clojure.main "$@"
In your clojure shell script, add this as the first line:
#!/usr/bin/env ng-clojure
Then make the clojure shell script executable and run it like
path/to/myscript.clj
OSX
brew install nailgun
ng-server
ng ng-cp ~/.m2/repository/org/clojure/clojure/1.5.1/clojure-1.5.1.jar
Then execute your script as above.
Update: Having used it for a while, it doesn't seem to work flawlessly. Sometimes I'm getting random errors that don't occur when running without nailgun, and sometimes there seems to be a memory leak that makes the nailgun JVM consume all memory over time, eventually making the system swap to disk. Haven't memory profiled this yet, but wanted to add this heads-up.
这篇关于加速clojure启动时间与nailgun的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!