-
Notifications
You must be signed in to change notification settings - Fork 36
/
je
executable file
·40 lines (36 loc) · 942 Bytes
/
je
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env ruby
# Help
def usage
puts <<END
Usage: je [ARGS]...
Options:
-v verbose mode
--version show version
END
exit
end
# Option parsing
$verbose = false
argv = ARGV
usage() if argv.length == 0
if argv[0] == '-v'
$verbose = true
argv = argv[1..-1]
elsif argv[0] == '--version'
require 'jemalloc/version'
puts "jemalloc version #{JEMalloc::VERSION}"
exit
end
usage() if argv.length == 0
# Set ENV for preloading jemalloc
lib_dir = File.expand_path('../lib/', File.dirname(__FILE__))
if File.exists? (lib_dir + "/jemalloc.so")
puts "=> Injecting jemalloc..." if $verbose
ENV.store("LD_PRELOAD", lib_dir + "/jemalloc.so")
elsif File.exists? (lib_dir + "/jemalloc.bundle")
puts "=> Injecting jemalloc..." if $verbose
ENV.store("DYLD_INSERT_LIBRARIES", lib_dir + "/jemalloc.bundle")
else
puts "=> Skip injecting jemalloc. Your platform is not supported." if $verbose
end
Kernel.exec *argv