Class: FPM::Fry::Plugin::Service::DSL
- Inherits:
-
Object
- Object
- FPM::Fry::Plugin::Service::DSL
- Defined in:
- lib/fpm/fry/plugin/service.rb
Instance Attribute Summary collapse
-
#limits ⇒ Hash<String,Tuple<Numeric,Numeric>]
readonly
Hash<String,Tuple<Numeric,Numeric>].
Instance Method Summary collapse
- #add!(builder) ⇒ Object private
- #chdir(dir = nil) ⇒ Object
- #command(*args) ⇒ Object
- #group(group = nil) ⇒ Object
-
#initialize(name) ⇒ DSL
constructor
private
A new instance of DSL.
-
#limit(name, soft, hard = soft) ⇒ Object
Sets a limit for this service.
- #name(name = nil) ⇒ Object
- #user(n = nil) ⇒ Object
Constructor Details
#initialize(name) ⇒ DSL
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DSL.
29 30 31 32 33 34 35 36 |
# File 'lib/fpm/fry/plugin/service.rb', line 29 def initialize(name) @name = name @command = [] @limits = {} @user = nil @group = nil @chdir = nil end |
Instance Attribute Details
#limits ⇒ Hash<String,Tuple<Numeric,Numeric>] (readonly)
Returns Hash<String,Tuple<Numeric,Numeric>].
26 27 28 |
# File 'lib/fpm/fry/plugin/service.rb', line 26 def limits @limits end |
Instance Method Details
#add!(builder) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/fpm/fry/plugin/service.rb', line 122 def add!(builder) init = builder.plugin('init') if init.systemd? add_systemd!(builder) elsif init.upstart? add_upstart!(builder) elsif init.sysv? add_sysv!(builder) end end |
#chdir ⇒ String? #chdir(dir) ⇒ String
107 108 109 110 111 112 |
# File 'lib/fpm/fry/plugin/service.rb', line 107 def chdir( dir = nil ) if dir @chdir = dir end @chdir end |
#command(*args) ⇒ Object
114 115 116 117 118 119 |
# File 'lib/fpm/fry/plugin/service.rb', line 114 def command( *args ) if args.any? @command = args end return @command end |
#group ⇒ String #group(name) ⇒ String
55 56 57 58 59 60 |
# File 'lib/fpm/fry/plugin/service.rb', line 55 def group( group = nil ) if group @group = group end return @group end |
#limit(name, soft, hard = soft) ⇒ Object
Sets a limit for this service. Valid limits are:
- core
- cpu
- data
- fsize
- memlock
- msgqueue
- nice
- nofile
- nproc
- rss
- rtprio
- sigpending
- stack
94 95 96 97 98 99 100 |
# File 'lib/fpm/fry/plugin/service.rb', line 94 def limit( name, soft, hard = soft ) unless LIMITS.include? name raise ArgumentError, "Unknown limit #{name.inspect}. Known limits are: #{LIMITS.inspect}" end @limits[name] = [soft,hard] return nil end |
#name ⇒ String #name(name) ⇒ String
43 44 45 46 47 48 |
# File 'lib/fpm/fry/plugin/service.rb', line 43 def name( name = nil ) if name @name = name end return @name end |
#user ⇒ String #user(name) ⇒ String
67 68 69 70 71 72 |
# File 'lib/fpm/fry/plugin/service.rb', line 67 def user( n = nil ) if n @user = n end return @user end |