Sha256: c07d190e6ab9d99cbe6cb7e84ac2e85ac871ec099b8bae27c1e80da0d5eb399d

Contents?: true

Size: 960 Bytes

Versions: 1

Compression:

Stored size: 960 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

STDOUT.sync = true

class Services
  def initialize
    @services = %w(rsyslog haproxy spamassassin spamassassin.update opendkim postfix dovecot)
  end

  def start
    puts "Starting Services..."
    @services.each { |service| system("monit start #{service}") }
    system("monit")

    puts "Starting Logtailer..."
    system("/usr/bin/logtailer.rb start")
  end

  def stop(signo)
    puts "Stopping Logtailer..."
    system("/usr/bin/logtailer.rb stop")

    puts "Stopping Services... SIGNAL: SIG#{Signal.signame(signo)}."
    system("monit quit")
    sleep(3)
    @services.reverse.each { |service| system("monit stop #{service}") }

    puts "Flushing Logtailer..."
    system("/usr/bin/logtailer.rb flush")

    exit
  end
end

trap('SIGINT') do |signo|
  Services.new.stop(signo)
end

trap('SIGTERM') do |signo|
  Services.new.stop(signo)
end

at_exit do
  # Clean up.
end

Services.new.start

sleep

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smartmachine-1.3.0 lib/smart_machine/templates/dotsmartmachine/config/emailer/docker/command.rb