Class: RakeUp::ServerTask

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/rakeup/server_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :server) {|_self| ... } ⇒ ServerTask

Returns a new instance of ServerTask.

Yields:

  • (_self)

Yield Parameters:



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rakeup/server_task.rb', line 25

def initialize(name = :server)
  @name = name
  @host = 'localhost'
  @port = 4567
  @pid_file = "tmp/#{name}.pid"
  @rackup_file = "#{name}.ru"
  @rackup_bin = "bundle exec rackup"
  @server = "thin"
  @echo_commands = true
  
  yield self if block_given?
  define_tasks
end

Instance Attribute Details

#echo_commandsObject

Returns the value of attribute echo_commands.



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

def echo_commands
  @echo_commands
end

#hostObject

Returns the value of attribute host.



11
12
13
# File 'lib/rakeup/server_task.rb', line 11

def host
  @host
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/rakeup/server_task.rb', line 10

def name
  @name
end

#pid_fileObject

Returns the value of attribute pid_file.



14
15
16
# File 'lib/rakeup/server_task.rb', line 14

def pid_file
  @pid_file
end

#portObject

Returns the value of attribute port.



12
13
14
# File 'lib/rakeup/server_task.rb', line 12

def port
  @port
end

#rackup_binObject

Returns the value of attribute rackup_bin.



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

def rackup_bin
  @rackup_bin
end

#rackup_fileObject

Returns the value of attribute rackup_file.



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

def rackup_file
  @rackup_file
end

#restart_commandObject

Returns the value of attribute restart_command.



23
24
25
# File 'lib/rakeup/server_task.rb', line 23

def restart_command
  @restart_command
end

#run_commandObject

Commands



20
21
22
# File 'lib/rakeup/server_task.rb', line 20

def run_command
  @run_command
end

#serverObject

Returns the value of attribute server.



13
14
15
# File 'lib/rakeup/server_task.rb', line 13

def server
  @server
end

#start_commandObject

Returns the value of attribute start_command.



21
22
23
# File 'lib/rakeup/server_task.rb', line 21

def start_command
  @start_command
end

#stop_commandObject

Returns the value of attribute stop_command.



22
23
24
# File 'lib/rakeup/server_task.rb', line 22

def stop_command
  @stop_command
end

Instance Method Details

#host_optionObject



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

def host_option
  host && "-o #{host}"
end

#rackup_command(options = nil) ⇒ Object



39
40
41
# File 'lib/rakeup/server_task.rb', line 39

def rackup_command(options = nil)
  [rackup_bin, "-s #{server}", host_option, "-p #{port}", "-P #{pid_file}", options, rackup_file].compact.join(' ')
end