Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MidiSmtpServer for incoming SMTP Service - Enables AUTH and STARTTLS #386

Closed
wants to merge 7 commits into from
13 changes: 12 additions & 1 deletion lib/mail_catcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ def run! options=nil
# Stash them away for later
@@options = options

# daemonize mode, reap the child automatically to prevent zombie
if options[:daemon] && pid = fork
Process.detach(pid)
# wait a second to make sure that all output is send before exit
sleep 2
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not sleeping a second the output from command line is printed too fast so that the output of starting mailcatcher will follow later. That confuses the user.

exit
end

# If we're running in the foreground sync the output.
unless options[:daemon]
$stdout.sync = $stderr.sync = true
Expand Down Expand Up @@ -219,7 +227,10 @@ def run! options=nil
else
puts "*** MailCatcher is now running as a daemon that cannot be quit."
end
Process.daemon
# when daemonize redirect standard input, standard output and standard error to /dev/null
$stdin.reopen "/dev/null"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-routing stdin, stdout and stderr was former handled by Process.daemon.
Read at https://ruby-doc.org/core-2.1.0/Process.html#method-c-daemon
Second paramter (noclose = nil)

$stdout.reopen "/dev/null", "a"
$stderr.reopen '/dev/null', 'a'
end
end
end
Expand Down