Commit fe533b30 authored by Patrick J Cherry's avatar Patrick J Cherry
Browse files

email: Reworked how poppassd/dict-proxy daemons are managed

They now always run in the foreground, and have no forking code
integrated.  Under sysvinit the forking is now managed by
stop-start-daemon.
parent 077a196a
......@@ -10,7 +10,7 @@ XS-Ruby-Versions: all
Package: symbiosis-email
Architecture: all
Pre-Depends: dpkg (>= 1.15.7.2)
Depends: symbiosis-common (>= 2015:1027), exim4-daemon-heavy (>= 4.84), dovecot-core (>= 1:2.2.0), dovecot-sieve, dovecot-managesieved, dovecot-imapd, dovecot-pop3d, adduser, make, clamav-daemon, clamav-freshclam, spamassassin, ruby, ruby-eventmachine (>= 1.0), ruby-daemons, gnutls-bin, ${misc:Depends}
Depends: symbiosis-common (>= 2015:1027), exim4-daemon-heavy (>= 4.84), dovecot-core (>= 1:2.2.0), dovecot-sieve, dovecot-managesieved, dovecot-imapd, dovecot-pop3d, adduser, make, clamav-daemon, clamav-freshclam, spamassassin, ruby, ruby-eventmachine (>= 1.0), gnutls-bin, ${misc:Depends}
Recommends: symbiosis-webmail, symbiosis-email-activesync
Replaces: bytemark-vhost-email, symbiosis-monit (<< 2011:1206), symbiosis-test
Breaks: symbiosis-monit (<< 2011:1206)
......
......@@ -10,13 +10,47 @@ fi
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Symbiosis: email dict proxy
# Description: Proxy service used by Dovecot for authentication
# Description: Proxy service used by Dovecot for authentication
### END INIT INFO
# Author: Patrick J Cherry <patrick@bytemark.co.uk>
DESC="Symbiosis: email dict proxy"
DAEMON=/usr/sbin/symbiosis-email-dict-proxy
NAME="ruby"
DAEMON="/usr/bin/ruby"
NAME="symbiosis-email-dict-proxy"
PIDFILE="/run/${NAME}.pid"
DAEMON_ARGS="/usr/sbin/symbiosis-email-dict-proxy"
#####
# These functions are cribbed from /lib/init/init-d-script and override them.
#
do_start_cmd() {
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--startas $DAEMON --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--make-pidfile --background \
--startas $DAEMON --exec $DAEMON -- $DAEMON_ARGS \
|| return 2
}
do_stop_cmd() {
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile ${PIDFILE} --exec $DAEMON
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 \
--pidfile ${PIDFILE} --exec $DAEMON
[ "$?" = 2 ] && return 2
rm -f $PIDFILE
return $RETVAL
}
......@@ -3,7 +3,7 @@ Description=Symbiosis: email dict proxy
[Service]
Type=simple
ExecStart=/usr/sbin/symbiosis-email-dict-proxy --foreground
ExecStart=/usr/sbin/symbiosis-email-dict-proxy
Restart=always
[Install]
......
......@@ -15,8 +15,42 @@ fi
# Author: Patrick J Cherry <patrick@bytemark.co.uk>
DESC="Symbiosis: email dict proxy"
DAEMON=/usr/sbin/symbiosis-email-poppassd
NAME="ruby"
DESC="Symbiosis: email poppass daemon"
DAEMON="/usr/bin/ruby"
NAME="symbiosis-email-poppassd"
PIDFILE="/run/${NAME}.pid"
DAEMON_ARGS="/usr/sbin/symbiosis-email-poppassd"
#####
# These functions are cribbed from /lib/init/init-d-script and override them.
#
do_start_cmd() {
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--startas $DAEMON --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--make-pidfile --background \
--startas $DAEMON --exec $DAEMON -- $DAEMON_ARGS \
|| return 2
}
do_stop_cmd() {
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile ${PIDFILE} --exec $DAEMON
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 \
--pidfile ${PIDFILE} --exec $DAEMON
[ "$?" = 2 ] && return 2
rm -f $PIDFILE
return $RETVAL
}
......@@ -3,7 +3,7 @@ Description=Symbiosis: email poppass daemon
[Service]
Type=simple
ExecStart=/usr/sbin/symbiosis-email-poppassd --foreground
ExecStart=/usr/sbin/symbiosis-email-poppassd
Restart=always
[Install]
......
......@@ -33,14 +33,12 @@ manual = help = false
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--manual', '-m', GetoptLong::NO_ARGUMENT ],
[ '--foreground', '-f', GetoptLong::NO_ARGUMENT ],
[ '--prefix', '-p', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--socket', '-s', GetoptLong::OPTIONAL_ARGUMENT ]
)
prefix = "/srv"
socket_path = "/run/dovecot/symbiosis-email-dict-proxy"
foreground = false
opts.each do |opt,arg|
case opt
......@@ -52,8 +50,6 @@ opts.each do |opt,arg|
prefix = arg
when '--socket'
socket_path = arg
when '--foreground'
foreground = true
end
end
......@@ -71,7 +67,6 @@ end
# Require these bits here, so we can generate the manpage without needing extra
# build-deps.
#
require 'daemons'
require 'eventmachine'
require 'syslog'
require 'symbiosis/utils'
......@@ -106,13 +101,6 @@ systemd_socket = nil
# syslog.info "Got socket #{SD_LISTEN_FDS_START + 0} from systemd"
# end
Daemons.daemonize({
:app_name => "ruby",
:ontop => foreground,
:dir_mode => :system,
:log_output => false
})
EventMachine.run do
begin
if systemd_socket
......
......@@ -33,14 +33,12 @@ manual = help = false
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--manual', '-m', GetoptLong::NO_ARGUMENT ],
[ '--foreground', '-f', GetoptLong::NO_ARGUMENT ],
[ '--prefix', '-p', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--port', '-P', GetoptLong::OPTIONAL_ARGUMENT ]
)
prefix = "/srv"
port = 106
foreground = false
opts.each do |opt,arg|
case opt
......@@ -52,8 +50,6 @@ opts.each do |opt,arg|
prefix = arg
when '--port'
port = arg
when '--foreground'
foreground = true
end
end
......@@ -78,7 +74,6 @@ end
# Require these bits here, so we can generate the manpage without needing extra
# build-deps.
#
require 'daemons'
require 'eventmachine'
require 'syslog'
require 'symbiosis/utils'
......@@ -99,13 +94,6 @@ Symbiosis::Email::PoppassHandler.syslog = syslog
# syslog.info "Got socket #{SD_LISTEN_FDS_START + 0} from systemd"
# end
Daemons.daemonize({
:app_name => "ruby",
:ontop => foreground,
:dir_mode => :system,
:log_output => false
})
EventMachine.run do
begin
EventMachine.start_server "127.0.0.1", port, Symbiosis::Email::PoppassHandler
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment