Class: Cybertrain::Background::Service

Inherits:
Object
  • Object
show all
Defined in:
cybertrain/background.rb

Overview

A background service: the default does nothing. Subclasses override all three methods. Distinctive names (service_start, not start): NOTES rules 10/34/62.

Instance Method Summary collapse

Instance Method Details

#service_name ⇒ String

Returns for the log and for Cybertrain::Background.register’s uniqueness check; non-empty in a subclass.

Returns:



36
37
38
# File 'cybertrain/background.rb', line 36

def service_name
  ""
end

#service_problem ⇒ String

What would make service_start refuse to start, found before the server binds its port (Cybertrain::Background.boot_problem), so serve reports it as a boot failure rather than raising after the banner.

Returns:

  • (String) —

    ”” when nothing is wrong



62
63
64
# File 'cybertrain/background.rb', line 62

def service_problem
  ""
end

#service_start(config) ⇒ Boolean

Starts the service (its thread, usually). Called once per serve; it must not block and should not raise.

Parameters:

Returns:

  • (Boolean) —

    true when it started something



45
46
47
# File 'cybertrain/background.rb', line 45

def service_start(config)
  false
end

#service_stop ⇒ nil

Asks the service to end. Called once at shutdown, also for a service whose service_start returned false: then it does nothing.

Returns:

  • (nil)


53
54
55
# File 'cybertrain/background.rb', line 53

def service_stop
  nil
end