Class: DJB::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/djb.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, svc = "/command/svc") ⇒ Service

Returns a new instance of Service.



17
18
19
# File 'lib/djb.rb', line 17

def initialize(root, svc="/command/svc")
    @root, @svc = root, svc
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



15
16
17
# File 'lib/djb.rb', line 15

def root
  @root
end

#svcObject (readonly)

Returns the value of attribute svc.



16
17
18
# File 'lib/djb.rb', line 16

def svc
  @svc
end

Instance Method Details

#alarmObject



81
82
83
# File 'lib/djb.rb', line 81

def alarm
    _svc('-a')
end

#continueObject



73
74
75
# File 'lib/djb.rb', line 73

def continue
    _svc('-c')
end

#downObject



61
62
63
# File 'lib/djb.rb', line 61

def down
    _svc('-d')
end

#env(name, *args) ⇒ Object

————————————————#



23
24
25
26
27
28
29
30
# File 'lib/djb.rb', line 23

def env(name, *args)
    fn = "#{@root}/env/#{name}"
    if args.size == 0
        return File.open(fn).read()
    else
        File.write(fn, args.join(""))
    end
end

#exitObject



97
98
99
# File 'lib/djb.rb', line 97

def exit
    _svc('-x')
end

#hangupObject



77
78
79
# File 'lib/djb.rb', line 77

def hangup
    _svc('-h')
end

#interruptObject



85
86
87
# File 'lib/djb.rb', line 85

def interrupt
    _svc('-i')
end

#killObject



93
94
95
# File 'lib/djb.rb', line 93

def kill
    _svc('-k')
end

#makeObject

Implemented in the base class. def fn() end



35
36
37
38
39
# File 'lib/djb.rb', line 35

def make
    Dir.chdir(File.dirname(fn())) do |d|
        system("make")
    end
end

#onceObject



65
66
67
# File 'lib/djb.rb', line 65

def once
    _svc('-o')
end

#pauseObject



69
70
71
# File 'lib/djb.rb', line 69

def pause
    _svc('-p')
end

#restartObject

————————————————#



43
44
45
# File 'lib/djb.rb', line 43

def restart
    terminate()    
end

#startObject



47
48
49
# File 'lib/djb.rb', line 47

def start
    up()
end

#stopObject



51
52
53
# File 'lib/djb.rb', line 51

def stop
    down()
end

#terminateObject



89
90
91
# File 'lib/djb.rb', line 89

def terminate
    _svc('-t')
end

#upObject

————————————————#



57
58
59
# File 'lib/djb.rb', line 57

def up
    _svc('-u')
end