Drip是Java虚拟机的启动器,提供比java命令更快的启动时间。 Drip脚本旨在成为java命令的替代品,只有更快的速度。
drip
快速的JVM启动,而不需要持久JVM的麻烦。(Fast JVM launching without the hassle of persistent JVMs.)
Github stars Tracking Chart
Drip是一个单一的bash脚本和一些C和Java代码。 它旨在与任何基于JVM的语言和任何地方的bash一起使用。
与其他旨在解决JVM启动问题的工具(例如,Nailgun,Cake)不同,Drip不使用持久的JVM。 在使用Clojure的Cake构建工具时,我们发现使用持久性JVM有许多陷阱。 主要的问题是持久JVM的状态随着时间的推移变得脏兮兮,如果遇到任何错误,就会产生奇怪的错误,并且要求自由使用蛋糕杀死,以防脏兮兮的原因。
Drip不用走这条路,而是采用不同的策略。 它保留了一个新的JVM,具有正确的类路径和其他JVM选项,因此您可以在需要时快速连接和使用它,然后将其丢弃。 Drip散列JVM选项,并存储有关以哈希值为名称的目录中如何连接到JVM的信息。
Overview
Name With Owner | ninjudd/drip |
---|---|
Primary Language | Shell |
Program language | Makefile (Language Count: 4) |
Platform | |
License: | Eclipse Public License 1.0 |
Release Count | 10 |
Last Release Name | 0.2.4 (Posted on ) |
First Release Name | 0.0.3 (Posted on ) |
Created At | 2012-08-24 05:12:32 |
Pushed At | 2021-01-27 05:51:38 |
Last Commit At | 2017-11-14 20:37:20 |
Stargazers Count | 1.5k |
Watchers Count | 52 |
Fork Count | 73 |
Commits Count | 252 |
Has Issues Enabled | |
Issues Count | 83 |
Issue Open Count | 33 |
Pull Requests Count | 17 |
Pull Requests Open Count | 4 |
Pull Requests Close Count | 2 |
Has Wiki Enabled | |
Is Archived | |
Is Fork | |
Is Locked | |
Is Mirror | |
Is Private |
Drip is a launcher for the Java Virtual Machine that provides much faster
startup times than the java
command. The drip
script is intended to be a
drop-in replacement for the java
command, only faster.
Drip is a single bash script and a little bit of C and Java code. It is intended
to work with any JVM-based language and anywhere bash is available.
How does it work?
Unlike other tools intended to solve the JVM startup problem (e.g. Nailgun,
Cake), Drip does not use a persistent JVM. There are many pitfalls to using a
persistent JVM, which we discovered while working on the Cake build tool for
Clojure. The main problem is that the state of the persistent JVM gets dirty
over time, producing strange errors and requiring liberal use of cake kill
whenever any error is encountered, just in case dirty state is the cause.
Instead of going down this road, Drip uses a different strategy. It keeps a
fresh JVM spun up in reserve with the correct classpath and other JVM options
so you can quickly connect and use it when needed, then throw it away. Drip
hashes the JVM options and stores information about how to connect to the JVM
in a directory with the hash value as its name.
Installation
The following instructions assume that ~/bin
is on your $PATH
. If that is
not the case, you can substitute your favorite location.
Standalone — We recommend this to get started quickly.
curl -L https://raw.githubusercontent.com/ninjudd/drip/master/bin/drip > ~/bin/drip
chmod 755 ~/bin/drip
Checkout — If you want to hack on Drip or follow the latest
development, this is the way to go.
git clone https://github.com/ninjudd/drip.git
cd drip && make prefix=~/bin install
Homebrew — This is a convenient way to brew drip on OS X.
brew install drip
Note: Installing brew requires gcc
. Here are instructions
for how to install it on OS X Mountain Lion.
Usage
You can call drip
with the same arguments as java
. Try it. The first time
you execute drip
with new arguments, it will take as long as a plain java
command, because it has to spin up a JVM from scratch, but after that it will be
fast.
For example, to start a Clojure repl with drip:
drip -cp clojure.jar clojure.main
The Drip JVM will eventually shut itself down if you never connect to it. The
time limit defaults to four hours, but you can change this by setting the
DRIP_SHUTDOWN
environment variable before calling drip
to set a timeout, in
minutes:
DRIP_SHUTDOWN=30 drip -cp clojure.jar clojure.main
This creates a Clojure repl as usual, either by starting up a new one or
connecting to a waiting JVM. But the JVM that is spun up to serve future
requests with the same classpath will have a 30-minute timeout to deactivation.
JVM Language Integration
For more information about how to integrate Drip with your favorite JVM
language, check out the wiki.
Advanced settings
Drip supports the following advanced settings.
Pre-Initialization
By default, Drip only loads your main class at startup, but you can tell Drip to
run additional code at startup. This can be used to load classes or execute any
initialization code you like. For a language like Clojure, which compiles code
on-the-fly, this can be used to precompile commonly used code by requiring it.
To tell Drip how to initialize a new JVM, use the DRIP_INIT
and
DRIP_INIT_CLASS
environment variables. DRIP_INIT
should be a
newline-separated list of args to be passed to the main()
function of
DRIP_INIT_CLASS
. DRIP_INIT_CLASS
defaults to the main class the JVM was
started with.
System Properties
Sometimes, you need to set Java system properties, but you don't want them to be
included in the JVM options used for hashing. In this case, use two dashes
instead of one, and the options won't be passed to the JVM at startup, instead
they will be passed at runtime. Keep in mind that any system properties passed
this way will not be set during initialization.
Environment Variables
Drip passes all environment variables exported at runtime to the JVM and merges
them into the map returned by System.getenv
. Keep in mind that the environment
isn't modified until we connect to the JVM; during initialization, the
environment will be derived from the previous process that launched the spare
JVM.
License
Drip is licensed under the EPL Eclipse Public License. See LICENSE for
details.