Module: Norikra::CLIUtil

Defined in:
lib/norikra/cli.rb

Class Method Summary collapse

Class Method Details

.register_common_start_options(klass) ⇒ Object



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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/norikra/cli.rb', line 11

def self.register_common_start_options(klass)
  klass.module_exec {
    ### Server options
    option :host, type: :string, default: nil, aliases: "-H", desc: 'host address that server listen [0.0.0.0]'
    option :port, type: :numeric, default: nil, aliases: "-P", desc: 'port that server uses [26571]'
    option :'ui-port', type: :numeric, default: nil, desc: 'port that Web UI server uses [26578]'

    option :stats, type: :string, default: nil, aliases: "-s", \
                   desc: 'status file path to load/dump targets and queries [none]'
    option :'stats-secondary', type: :string, default: nil, \
                   desc: 'status file secondary path, to dump stats with date/time, like "stats.%Y%m%d.json" [none]'
    option :'suppress-dump-stat', type: :boolean, default: false, \
                   desc: 'specify not to update stat file with updated targets/queries on runtime [false]'
    option :'dump-stat-interval', type: :numeric, default: nil, \
                   desc: 'interval(seconds) of status file dumps on runtime [none (on shutdown only)]'

    option :shutoff, type: :boolean, default: false, desc: '[EXPERIMENTAL] enable "shutoff" mode, to reject input data under high memory usage'
    option :'shutoff-threshold', type: :numeric, default: 90, desc: 'threshold percent of heap memory usage to turn "shutoff mode" on'
    option :'shutoff-check-interval', type: :numeric, default: 10, desc: 'interval seconds to turn "shutoff mode" on/off'

    option :'ui-context-path', type: :string, default: nil, desc: 'Web UI context path'

    ### Daemonize options
    option :daemonize, type: :boolean, default: false, aliases: "-d", \
                       desc: 'daemonize Norikra server [false (foreground)]'
    option :pidfile, type: :string, default: DEFAULT_PID_PATH, aliases: "-p", \
                     desc: "pidfile path when daemonized [#{DEFAULT_PID_PATH}]"
    option :outfile, type: :string, default: nil, \
                     desc: "stdout redirect file when daemonized [${logdir}/norikra.out]"

    ### JVM options
    option :'bare-jvm', type: :boolean, default: false, desc: "use JVM without any recommended options"
    option :'gc-log', type: :string, default: nil, desc: "output gc logs on specified file path"

    ### Performance options
    # performance predefined configuration sets
    option :micro, type: :boolean, default: false, \
           desc: 'development or testing (inbound:0, outbound:0, route:0, timer:0, rpc:2, web:2)'
    option :small, type: :boolean, default: false, \
           desc: 'virtual or small scale servers (inbound:2, outbount:2, route:2, timer:2, rpc:9, web:9)'
    option :middle, type: :boolean, default: false, \
           desc: 'rackmount servers (inbound:4, outbound:4, route:4, timer:4, rpc:17, web:17)'
    option :large, type: :boolean, default: false, \
           desc: 'high performance servers (inbound: 8, outbound: 8, route:8, timer:8, rpc:49, web:49)'
    # Esper
    option :'inbound-threads',  type: :numeric, default: nil, desc: 'number of threads for inbound data'
    option :'outbound-threads', type: :numeric, default: nil, desc: 'number of threads for outbound data'
    option :'route-threads',    type: :numeric, default: nil, desc: 'number of threads for events routing for query execution'
    option :'timer-threads',    type: :numeric, default: nil, desc: 'number of threads for internal timers for query execution'
    ### about capacity options of esper's capacity-bound queue processing, see Esper's thread reference.
    # http://esper.codehaus.org/esper-4.10.0/doc/reference/en-US/html/configuration.html#config-engine-threading-advanced
    # default nil: unbound queueing
    option :'inbound-thread-capacity',  type: :numeric, default: nil
    option :'outbound-thread-capacity', type: :numeric, default: nil
    option :'route-thread-capacity',    type: :numeric, default: nil
    option :'timer-thread-capacity',    type: :numeric, default: nil
    # Jetty
    option :'rpc-threads', type: :numeric, default: nil, desc: 'number of threads for rpc handlers'
    option :'web-threads', type: :numeric, default: nil, desc: 'number of threads for WebUI handlers'

    ### Logging options
    option :logdir, type: :string, default: nil, aliases: "-l", \
           desc: "directory path of logfiles when daemonized [nil (console for foreground)]"
    option :'log-filesize', type: :string, default: nil, desc: 'log rotation size [10MB]'
    option :'log-backups' , type: :numeric, default: nil, desc: 'log rotation backups [10]'
    option :'log-buffer-lines', type: :numeric, default: nil, desc: 'log lines to fetch from API [1000]'
    option :'log4j-properties-path', type: :string, default: nil, desc: 'path to log4j.properties. ignore other log* options when this option is present'

    ### Loglevel options
    option :'more-quiet',   type: :boolean, default: false,                desc: 'set loglevel as ERROR'
    option :quiet,          type: :boolean, default: false, aliases: "-q", desc: 'set loglevel as WARN'
    option :verbose,        type: :boolean, default: false, aliases: "-v", desc: 'set loglevel as DEBUG'
    option :'more-verbose', type: :boolean, default: false,                desc: 'set loglevel as TRACE'
  }
end