-
Notifications
You must be signed in to change notification settings - Fork 34
/
vertexdb_admin
executable file
·52 lines (42 loc) · 938 Bytes
/
vertexdb_admin
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
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env ruby
require "rubygems"
require "net/http"
$port = ARGV.shift
DOMAIN = '127.0.0.1'
def show_help
puts <<-TT
VertexDB maintaning tool
------------------------
Usage: vertexdb_admin <port> <command> [<options>]
Avaliable commands:
backup
clear
collect_garbage
TT
end
def send_request uri
res = ""
puts "-- SENDING #{uri}"
$connection.get(uri) {|r| res += r }
puts ">>> " + res
end
if ARGV.index('--help') || ARGV.index('-h') || ARGV.size == 0
show_help
exit
end
$connection = Net::HTTP.start(DOMAIN, $port)
puts "== connected to #{DOMAIN}:#{$port}"
case ARGV.shift
when 'backup'
send_request '/?action=backup'
puts "== backup made"
when 'clear'
send_request '/?action=select&op=rm'
puts "== root nodes removed"
when 'collect_garbage'
send_request '/?action=collectGarbage'
puts "== garbage collected"
else
puts "Undefined command"
puts "See vertexdb_admin --help"
end