* [gentoo-user] MailScanner: caught SIGTERM, aborting
@ 2009-05-24 9:10 Jarry
2009-05-24 9:48 ` Mike Kazantsev
0 siblings, 1 reply; 7+ messages in thread
From: Jarry @ 2009-05-24 9:10 UTC (permalink / raw
To: gentoo-user
Hi,
For whatever reason I can not stop/start MailScanner cleanly:
# /etc/init.d/MailScanner stop
* Stopping MailScanner...
* MailScanner: caught SIGTERM, aborting
# /etc/init.d/MailScanner start
* WARNING: MailScanner has already been started
Actually, MailScanner stops, but sendmail which has been
started by MailScanner init script is still there running:
# ps -e | grep sendmail
18676 ? 00:00:00 sendmail
18679 ? 00:00:00 sendmail
Even whenn I killall sendmail, I still get the above mentioned
warning, and can not start MailScanner. And that is a problem,
because MailScanner is restarted every hour (to prevent eating
all resources). I checked /var/run and /var/lock, there is
no trace of MailScanner or sendmail running, yet I can not
re-start Mailscanner. How can I fix this problem?
Jarry
--
_______________________________________________________________
This mailbox accepts e-mails only from selected mailing-lists!
Everything else is considered to be spam and therefore deleted.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] MailScanner: caught SIGTERM, aborting
2009-05-24 9:10 [gentoo-user] MailScanner: caught SIGTERM, aborting Jarry
@ 2009-05-24 9:48 ` Mike Kazantsev
2009-05-24 13:37 ` Jarry
0 siblings, 1 reply; 7+ messages in thread
From: Mike Kazantsev @ 2009-05-24 9:48 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 2160 bytes --]
On Sun, 24 May 2009 11:10:04 +0200
Jarry <mr.jarry@gmail.com> wrote:
> # /etc/init.d/MailScanner stop
> * Stopping MailScanner...
> * MailScanner: caught SIGTERM, aborting
Looks like there's a line in "stop" section that kills the script
itself. Try looking for a lines like these:
pkill MailScanner
killall MailScanner
start-stop-daemon --stop --name MailScanner
Sure, they might be killing the app as well (if the process has
MailScanner in it's name), but there should be full path or pid-based
line instead, so the initscript will exit cleanly.
> # /etc/init.d/MailScanner start
> * WARNING: MailScanner has already been started
Following command should "wipe" initscript memory:
/etc/init.d/MailScanner zap
...so it'll think MailScanner wasn't even started, but that should be
used as a workaround rather than a solution since it leaves init-system
in different state than it thinks it is.
Direct effect is that it won't execute "stop" action on shutdown since
it won't know the script even started.
> Actually, MailScanner stops, but sendmail which has been
> started by MailScanner init script is still there running:
>
> # ps -e | grep sendmail
> 18676 ? 00:00:00 sendmail
> 18679 ? 00:00:00 sendmail
Could be because of aforementioned script "self-destruction".
If sendmail really started by the same script, not as a dependency,
that is.
> Even whenn I killall sendmail, I still get the above mentioned
> warning, and can not start MailScanner. And that is a problem,
> because MailScanner is restarted every hour (to prevent eating
> all resources). I checked /var/run and /var/lock, there is
> no trace of MailScanner or sendmail running, yet I can not
> re-start Mailscanner. How can I fix this problem?
Try using "start-stop-daemon -m/-p/--exec" to start and stop binaries,
instead of relying on process names (which can be easily changed, btw)
and try to use app-created pidfiles, if the launched app has this
capability, since it should know better which of it's processes should
receive stop signal.
--
Mike Kazantsev // fraggod.net
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] MailScanner: caught SIGTERM, aborting
2009-05-24 9:48 ` Mike Kazantsev
@ 2009-05-24 13:37 ` Jarry
2009-05-24 14:22 ` Mike Kazantsev
2009-05-24 22:39 ` Stroller
0 siblings, 2 replies; 7+ messages in thread
From: Jarry @ 2009-05-24 13:37 UTC (permalink / raw
To: gentoo-user
Mike Kazantsev wrote:
>> # /etc/init.d/MailScanner stop
>> * Stopping MailScanner...
>> * MailScanner: caught SIGTERM, aborting
>
> Looks like there's a line in "stop" section that kills the script
> itself. Try looking for a lines like these:
> pkill MailScanner
> killall MailScanner
> start-stop-daemon --stop --name MailScanner
The /etc/init.d/MailScanner script looks so:
----------------------------------
#!/sbin/runscript
opts="${opts} reload"
depend() {
need net mta
use logger dns }
start() {
ebegin "Starting MailScanner"
/usr/sbin/check_MailScanner >/dev/null
RETVAL=$?
[ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner
[ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner.off
eend ${RETVAL}
}
stop() {
ebegin "Stopping MailScanner"
killall -15 MailScanner
RETVAL=$?
[ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner
[ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner.off
eend ${RETVAL}
}
# restart () {} and reload () {} removed
----------------------------------
> Sure, they might be killing the app as well (if the process has
> MailScanner in it's name), but there should be full path or pid-based
> line instead, so the initscript will exit cleanly.
>
>> # /etc/init.d/MailScanner start
>> * WARNING: MailScanner has already been started
>
> Following command should "wipe" initscript memory:
>
> /etc/init.d/MailScanner zap
Yes, this works. But as you said, it is just workaround. Not very
clean solution...
>> Actually, MailScanner stops, but sendmail which has been
>> started by MailScanner init script is still there running:
>>
>> # ps -e | grep sendmail
>> 18676 ? 00:00:00 sendmail
>> 18679 ? 00:00:00 sendmail
>
> Could be because of aforementioned script "self-destruction".
> If sendmail really started by the same script, not as a dependency,
> that is.
Don't know exactly how sendmail is started, but according to
MailScanner install messages, I had to remove it from default
runlevel. MailScanner itself takes care of starting sendmail...
Jarry
--
_______________________________________________________________
This mailbox accepts e-mails only from selected mailing-lists!
Everything else is considered to be spam and therefore deleted.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] MailScanner: caught SIGTERM, aborting
2009-05-24 13:37 ` Jarry
@ 2009-05-24 14:22 ` Mike Kazantsev
2009-05-24 14:36 ` Jarry
2009-05-24 22:39 ` Stroller
1 sibling, 1 reply; 7+ messages in thread
From: Mike Kazantsev @ 2009-05-24 14:22 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 3270 bytes --]
On Sun, 24 May 2009 15:37:51 +0200
Jarry <mr.jarry@gmail.com> wrote:
> Mike Kazantsev wrote:
>
> > Looks like there's a line in "stop" section that kills the script
> > itself. Try looking for a lines like these:
> > pkill MailScanner
> > killall MailScanner
> > start-stop-daemon --stop --name MailScanner
>
...
> depend() {
> need net mta
> use logger dns }
That's what probably starts sendmail as a dependency (mta), so if you
want to stop both MailScanner and sendmail you can just use
/etc/init.d/sendmail stop
...or something like that (I'm not sure about initscript name for
sendmail) - it should stop everything that depends on sendmail
(including MailScanner) then the sendmail itself.
> stop() {
> ebegin "Stopping MailScanner"
And here's the killer line:
> killall -15 MailScanner
I'd still suggest looking through available docs to see if the app can
create pidfile for itself and replacing that line with following:
start-stop-daemon --stop -p /path/to/pidfile
It'll give error code if it won't find the process, just as killall
does.
"-15" is SIGTERM (I guess that's true for all gentoo platforms) and is
default for nearly all kill-like commands, so there's little need to
specify it explicitly in gentoo.
And if you want a faster solution, I see at least two options:
1. Looking at "ps aux | grep MailScanner" output to see exact
invocation line and using one of the following:
start-stop-daemon --stop --exec /path/to/bin/MailScanner
pkill -f /path/to/bin/MailScanner
I'd prefer first one, for consistency.
2. Just rename init.d script to something w/o MailScanner in it's name.
It might break something only if any other scripts depend on this
one, but it sure looks like the easiest way to me ;)
> RETVAL=$?
> [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner
> [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner.off
> eend ${RETVAL}
> }
...
> Don't know exactly how sendmail is started, but according to
> MailScanner install messages, I had to remove it from default
> runlevel. MailScanner itself takes care of starting sendmail...
That seems strange, since sendmail should be already started as a
dependency anyway, so it shouldn't hurt to have it at any runlevel.
But since there's a check on killall and you've mentioned
self-restarting mechanism, I guess it might indeed restart itself and
sendmail independently of init-scripts, so removing sendmail from
runlevel serves exactly one purpose: it's init-script won't fail if the
process won't be there.
Also it looks like leaving sendmail running after MailScanner itself
was closed is expected behaviour or app (not initscript) bug, since
there's no mention of sendmail stopping in the script (unless it checks
that /var/lock paths) and MailScanner didn't close it upon receiving
SIGTERM, which seem to be expected way to stop it.
All in all, I think there's no reason to worry about why and how
sendmail is started as long as it works, so bogus killall line should
be the only wrong thing here.
--
Mike Kazantsev // fraggod.net
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] MailScanner: caught SIGTERM, aborting
2009-05-24 14:22 ` Mike Kazantsev
@ 2009-05-24 14:36 ` Jarry
2009-05-25 0:17 ` Mike Kazantsev
0 siblings, 1 reply; 7+ messages in thread
From: Jarry @ 2009-05-24 14:36 UTC (permalink / raw
To: gentoo-user
Mike Kazantsev wrote:
>>> Looks like there's a line in "stop" section that kills the script
>>> itself. Try looking for a lines like these:
>>> pkill MailScanner
>>> killall MailScanner
>>> start-stop-daemon --stop --name MailScanner
> ...
>> depend() {
>> need net mta
>> use logger dns }
>
> That's what probably starts sendmail as a dependency (mta), so if you
> want to stop both MailScanner and sendmail you can just use
>
> /etc/init.d/sendmail stop
# /etc/init.d/sendmail stop
* Stopping MailScanner...
* MailScanner: caught SIGTERM, aborting
* ERROR: cannot stop sendmail as MailScanner is still up
# /etc/init.d/MailScanner stop
* Stopping MailScanner...
* MailScanner: caught SIGTERM, aborting
# /etc/init.d/sendmail stop
* Stopping MailScanner...
* MailScanner: caught SIGTERM, aborting
* ERROR: cannot stop sendmail as MailScanner is still up
As you see, it does not work. I think that start/stop script
is somehow screwed. I'm going to ask on mailscanner mailing list.
Thanks for your effort.
Jarry
--
_______________________________________________________________
This mailbox accepts e-mails only from selected mailing-lists!
Everything else is considered to be spam and therefore deleted.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] MailScanner: caught SIGTERM, aborting
2009-05-24 14:36 ` Jarry
@ 2009-05-25 0:17 ` Mike Kazantsev
0 siblings, 0 replies; 7+ messages in thread
From: Mike Kazantsev @ 2009-05-25 0:17 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1435 bytes --]
On Sun, 24 May 2009 16:36:28 +0200
Jarry <mr.jarry@gmail.com> wrote:
> Mike Kazantsev wrote:
>
> >>> Looks like there's a line in "stop" section that kills the script
> >>> itself. Try looking for a lines like these:
> >>> pkill MailScanner
> >>> killall MailScanner
> >>> start-stop-daemon --stop --name MailScanner
> > ...
> >> depend() {
> >> need net mta
> >> use logger dns }
> >
> > That's what probably starts sendmail as a dependency (mta), so if you
> > want to stop both MailScanner and sendmail you can just use
> >
> > /etc/init.d/sendmail stop
>
> # /etc/init.d/sendmail stop
> * Stopping MailScanner...
> * MailScanner: caught SIGTERM, aborting
> * ERROR: cannot stop sendmail as MailScanner is still up
>
> # /etc/init.d/MailScanner stop
> * Stopping MailScanner...
> * MailScanner: caught SIGTERM, aborting
> # /etc/init.d/sendmail stop
> * Stopping MailScanner...
> * MailScanner: caught SIGTERM, aborting
> * ERROR: cannot stop sendmail as MailScanner is still up
>
> As you see, it does not work. I think that start/stop script
> is somehow screwed. I'm going to ask on mailscanner mailing list.
> Thanks for your effort.
But you didn't change the script, of course it WILL fail just as it did.
Replace killall line with something sensible and only then try to use
it. It's obviously broken otherwise.
--
Mike Kazantsev // fraggod.net
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] MailScanner: caught SIGTERM, aborting
2009-05-24 13:37 ` Jarry
2009-05-24 14:22 ` Mike Kazantsev
@ 2009-05-24 22:39 ` Stroller
1 sibling, 0 replies; 7+ messages in thread
From: Stroller @ 2009-05-24 22:39 UTC (permalink / raw
To: gentoo-user
On 24 May 2009, at 14:37, Jarry wrote:
> ...
> The /etc/init.d/MailScanner script looks so:
> ----------------------------------
> #!/sbin/runscript
> opts="${opts} reload"
> depend() {
> need net mta
> use logger dns }
>
> start() {
> ebegin "Starting MailScanner"
> /usr/sbin/check_MailScanner >/dev/null
> RETVAL=$?
> [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner
> [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner.off
> eend ${RETVAL}
> }
>
> stop() {
> ebegin "Stopping MailScanner"
> killall -15 MailScanner
> RETVAL=$?
> [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner
> [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner.off
> eend ${RETVAL}
> }
> # restart () {} and reload () {} removed
> ----------------------------------
That's the ugliest init.d script ever. It looks like it fell out of
the ugly tree, hit every branch on the way down and now not even its
mother could love it. &c &c.
Suggest you follow Mike's advice & rewrite the script based on the
other examples installed on your system, the ones written by Gentoo
devs. Unfortunately, if you don't know Bash very well, this may be a
bit of a mission, but I'm afraid it needs doing.
The script needs to save the process ID of the process that it starts
when it opens the application, then to stop the app it needs to kill
that specific PID, calling it by number. It needs to check that the
commands have worked - for instance: was it successful when it
executed `kill $PID`? See Example 6-1 of the Bash Scripting Guide <http://tldp.org/LDP/abs/html/exit-status.html
>. See also use of special variable $! in chapter 9 of ABSGuide and
also <http://www.unix.com/shell-programming-scripting/26377-pid-bash.html
>, but as Mike observes start-stop-daemon should take care of that
for you.
Stroller.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-05-25 0:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-24 9:10 [gentoo-user] MailScanner: caught SIGTERM, aborting Jarry
2009-05-24 9:48 ` Mike Kazantsev
2009-05-24 13:37 ` Jarry
2009-05-24 14:22 ` Mike Kazantsev
2009-05-24 14:36 ` Jarry
2009-05-25 0:17 ` Mike Kazantsev
2009-05-24 22:39 ` Stroller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox