Sha256: 75cafc7e5466ff97c31d0716893510718905cd442e926c320cc256e1c1dcbefd
Contents?: true
Size: 1.07 KB
Versions: 33
Compression:
Stored size: 1.07 KB
Contents
require "foreman/export" class Foreman::Export::Inittab < Foreman::Export::Base def export app = self.app || File.basename(engine.directory) user = self.user || app log_root = self.log || "/var/log/#{app}" inittab = [] inittab << "# ----- foreman #{app} processes -----" engine.procfile.entries.inject(1) do |index, process| 1.upto(self.concurrency[process.name]) do |num| id = app.slice(0, 2).upcase + sprintf("%02d", index) port = engine.port_for(process, num, self.port) inittab << "#{id}:4:respawn:/bin/su - #{user} -c 'PORT=#{port} #{process.command} >> #{log_root}/#{process.name}-#{num}.log 2>&1'" index += 1 end index end inittab << "# ----- end foreman #{app} processes -----" inittab = inittab.join("\n") + "\n" if location == "-" puts inittab else FileUtils.mkdir_p(log_root) rescue error "could not create #{log_root}" FileUtils.chown(user, nil, log_root) rescue error "could not chown #{log_root} to #{user}" write_file(location, inittab) end end end
Version data entries
33 entries across 33 versions & 1 rubygems