Class: FPM::Fry::Plugin::Service::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/fry/plugin/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#limitsHash<String,Tuple<Numeric,Numeric>] (readonly)

Returns Hash<String,Tuple<Numeric,Numeric>].

Returns:

  • (Hash<String,Tuple<Numeric,Numeric>])

    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

#chdirString? #chdir(dir) ⇒ String

Overloads:

  • #chdirString?

    Returns working directory of the service.

    Returns:

    • (String, nil)

      working directory of the service

  • #chdir(dir) ⇒ String

    Returns working directory of the service.

    Parameters:

    • dir (String)

      new working directory of the service

    Returns:

    • (String)

      working directory of the service



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

#groupString #group(name) ⇒ String

Overloads:

  • #groupString

    Returns the linux user group this service should run as.

    Returns:

    • (String)

      the linux user group this service should run as

  • #group(name) ⇒ String

    Returns the linux user group this service should run as.

    Parameters:

    • name (String)

      new linux user group this service should run as

    Returns:

    • (String)

      the linux user group this service should run as



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

Parameters:

  • name (String)

    see above list for valid limits

  • soft (Numeric, "unlimited")

    soft limit

  • hard (Numeric, "unlimited") (defaults to: soft)

    hard limit

See Also:



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

#nameString #name(name) ⇒ String

Overloads:

  • #nameString

    Returns this service’s name.

    Returns:

    • (String)

      this service’s name

  • #name(name) ⇒ String

    Returns this service’s name.

    Parameters:

    • name (String)

      new name for this service

    Returns:

    • (String)

      this service’s name



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

#userString #user(name) ⇒ String

Overloads:

  • #userString

    Returns the linux user this service should run as.

    Returns:

    • (String)

      the linux user this service should run as

  • #user(name) ⇒ String

    Returns the linux user this service should run as.

    Parameters:

    • name (String)

      new linx user this service should run as

    Returns:

    • (String)

      the linux user this service should run as



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