/
nodes.ml
42 lines (32 loc) · 1.15 KB
/
nodes.ml
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
(* of course, this will only work on the right OS ;) *)
module Node = struct
let exec = "./arakoon.native"
let names = ["arakoon_0";"arakoon_1";"arakoon_2"]
let cfg_name = (Unix.getcwd()) ^ "/cfg/arakoon.ini"
let _node_cmd fmt name =
let cmd = Printf.sprintf fmt exec name cfg_name in
print_endline cmd;
Sys.command cmd
let start name = _node_cmd "%s --node %s -config %s -daemonize" name
let stop name = _node_cmd "pkill -f '%s --node %s -config %s'" name
let start_all () =
List.iter (fun n -> ignore (start n)) names
let stop_all () =
List.iter (fun n -> ignore (stop n)) names
let monitor_all () =
let tab x = Printf.sprintf
"--tab-with-profile=Default -e 'tail -f /tmp/%s/%s.log' -t '%s' "
x x x
in
let tabs = List.map tab names in
let cmd = List.fold_left (^) "gnome-terminal " tabs in
print_endline cmd;
Sys.command cmd
let mkdirs () =
let mkdir x =
let dir_name = Printf.sprintf "/tmp/%s" x in
Unix.mkdir dir_name 0o755
in List.map mkdir names
let clean_dirs () =
List.iter (fun name -> ignore (Sys.command ("rm -rf /tmp/" ^ name))) names
end