Class: MailReceiver::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/mail-receiver/cli.rb

Instance Method Summary collapse

Instance Method Details

#restartObject



45
46
47
48
# File 'lib/mail-receiver/cli.rb', line 45

def restart
  MailReceiver::Daemon.init(options)
  MailReceiver::Daemon.restart_process
end

#startObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mail-receiver/cli.rb', line 14

def start
  MailReceiver::Daemon.init(options) do
    begin
      rails_env = ::File.expand_path('./config/environment', options[:root])
      require rails_env
    rescue => e
      puts "You need run this command under GitLab root."
      return
    end

    Mailman.config.logger = Logger.new($stdout)
    Mailman.config.rails_root = options[:root]

    Mailman.config.logger.info "Starting gitlab-mail-receiver..."
    Mailman::Application.run do
      to '%user%+%suffix%@%host%' do
        @receiver = MailReceiver::Receiver.new(message, logger: Mailman.config.logger)
        @receiver.process!
      end
    end
  end
  MailReceiver::Daemon.start_process
end

#stopObject



39
40
41
42
# File 'lib/mail-receiver/cli.rb', line 39

def stop
  MailReceiver::Daemon.init(options)
  MailReceiver::Daemon.stop_process
end

#versionObject



51
52
53
# File 'lib/mail-receiver/cli.rb', line 51

def version
  puts "gitlab-mail-receiver #{MailReceiver.version}"
end