Class: Capistrano::Cluster::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/cluster/service.rb

Defined Under Namespace

Modules: DSL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Service

Returns a new instance of Service.



5
6
7
8
# File 'lib/capistrano/cluster/service.rb', line 5

def initialize(name, &block)
  @name = name
  instance_eval(&block)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/capistrano/cluster/service.rb', line 4

def name
  @name
end

Instance Method Details

#log_file(*args) ⇒ Object



40
41
42
43
# File 'lib/capistrano/cluster/service.rb', line 40

def log_file(*args)
  @log_file = args.first if args.length > 0
  @log_file || "/var/log/service.#{@name}.log"
end

#pid_file(*args) ⇒ Object



20
21
22
23
# File 'lib/capistrano/cluster/service.rb', line 20

def pid_file(*args)
  @pid_file = args.first if args.length > 0
  @pid_file || "/var/run/#{@name}.pid"
end

#reload(*args) ⇒ Object



25
26
27
28
# File 'lib/capistrano/cluster/service.rb', line 25

def reload(*args)
  @reload = args.first if args.length > 0
  @reload || "stop;start"
end

#scriptObject



45
46
47
# File 'lib/capistrano/cluster/service.rb', line 45

def script
  file("service", name: name, start_cmd: start, pid_file: pid_file, working_dir: working_dir, reload_cmd: reload, stop_cmd: stop, user: user)
end

#start(*args) ⇒ Object



10
11
12
13
# File 'lib/capistrano/cluster/service.rb', line 10

def start(*args)
  @start = args.first if args.length > 0
  @start || fail("no start command defined for #{@name}")
end

#stop(*args) ⇒ Object



30
31
32
33
# File 'lib/capistrano/cluster/service.rb', line 30

def stop(*args)
  @stop = args.first if args.length > 0
  @stop || "kill -TERM $(< #{pid_file})"
end

#user(*args) ⇒ Object



35
36
37
38
# File 'lib/capistrano/cluster/service.rb', line 35

def user(*args)
  @user = args.first if args.length > 0
  @user
end

#working_dir(*args) ⇒ Object



15
16
17
18
# File 'lib/capistrano/cluster/service.rb', line 15

def working_dir(*args)
  @working_dir = args.first if args.length > 0
  @working_dir || "/tmp"
end