Module: Prosody

Defined in:
lib/diaspora-prosody-config.rb

Constant Summary collapse

NAME =
'diaspora-prosody-config'.freeze
GEMDIR =
Gem::Specification.find_by_name(NAME).gem_dir.freeze
WRAPPERCFG =
"#{GEMDIR}/etc/prosody.cfg.lua".freeze
DIASPORACFG =
"#{FileUtils.pwd}/config/prosody.cfg.lua".freeze

Class Method Summary collapse

Class Method Details

.startObject



35
36
37
38
39
40
41
42
43
# File 'lib/diaspora-prosody-config.rb', line 35

def self.start
  if check_sanity.nil?
    @prosody_pid = Process.spawn("#{find_binary} --config #{WRAPPERCFG}")
    # Prosody was forked into background
    # Let's wait till the Wrapper
    # will be killed or prosody itself
    Process.waitpid(@prosody_pid)
  end
end

.update_configuration(opts = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/diaspora-prosody-config.rb', line 45

def self.update_configuration(opts = {})
  # update prosody cfg in diaspora config dir
  gemcfg = "#{WRAPPERCFG}.tpl"
  unless File.exist?(DIASPORACFG)
    FileUtils.cp(gemcfg, DIASPORACFG)
  end

  config = File.read(DIASPORACFG)
  config_params(opts).each do |k, v|
    config.gsub!(/\#\{#{k}\}/, "#{v}")
  end
  File.open(WRAPPERCFG, 'w') {|f| f.write(config) }
  # check if prosody is available
  check_sanity
end