2018-09-17 11:41:14 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-21 02:01:33 -03:00
|
|
|
require 'yaml'
|
|
|
|
|
2016-02-06 19:00:29 -08:00
|
|
|
module Puma
|
|
|
|
class StateFile
|
|
|
|
def initialize
|
|
|
|
@options = {}
|
|
|
|
end
|
|
|
|
|
2020-05-06 23:13:35 -04:00
|
|
|
def save(path, permission = nil)
|
|
|
|
File.open(path, "w") do |file|
|
|
|
|
file.chmod(permission) if permission
|
|
|
|
file.write(YAML.dump(@options))
|
|
|
|
end
|
2016-02-06 19:00:29 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def load(path)
|
|
|
|
@options = YAML.load File.read(path)
|
|
|
|
end
|
|
|
|
|
2020-05-23 19:27:51 +02:00
|
|
|
FIELDS = %w!control_url control_auth_token pid running_from!
|
2016-02-06 19:00:29 -08:00
|
|
|
|
|
|
|
FIELDS.each do |f|
|
|
|
|
define_method f do
|
|
|
|
@options[f]
|
|
|
|
end
|
|
|
|
|
|
|
|
define_method "#{f}=" do |v|
|
|
|
|
@options[f] = v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|