[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#680592: lsb-base: reporting errors and diagnostics in init scripts



Jeff Licquia <licquia@debian.org> writes:

> It does feel that way.  OTOH, on a starting system, the information you
> printed to the console could scroll off-screen and be lost.  With the
> lsb-base function, a hook could capture and log that information.  So
> there's a tradeoff here, I think.

The thing that I've never liked about that argument is that init scripts
are not only run during system startup.  They're also routinely run by
system admins from the command line, particularly when they fail during
startup, at which point providing good error information is important.
That's why I feel like being somewhat verbose is still worthwhile.

> Would it be acceptable to do something like this:

> log_action_msg "Loading AFS module $MODULEDIR/$LIBAFS"
> load_afs_module
> if afs_module_load_failed; then
>   log_failure_msg "Module not found; see \
>      /usr/share/doc/openafs-client/README.modules"
> fi

> (with additional info like the message you currently write put into the
> docs)

I could, yeah, and I see some other packages have done that, but I'd
rather not if I can help it.  The above will generally produce a line
that's longer than 80 characters, which has its own readability issues.
(And while I've not yet done so, I've thought about giving people the
immediate solution directly in the message -- namely, "install
openafs-modules-dkms" -- which would make the message even longer.)

One thing I did consider is using log_warning_msg for each one of the
lines individually, although that seems to add a spurious "..." to the end
of each line if I'm reading the source correctly.

If there were some general supported function for printing out an extended
warning, that seems like it would fill this gap.  Even if it just takes
one line, I could use it repeatedly.

> I've seen that happen with other scripts.  I agree that it probably
> involves some arcane shell-fu, but I would think that lsb-base should do
> the arcane shell-fu for you.

That would be *great*.  That's exactly what I was hoping for.

> Something like this:

> log_begin_msg "Starting AFS services: afsd"
> start_daemon /sbin/afsd || log_start_failure
> log_success_msg "."

> Success could look something like this:

> [ok] Starting AFS services: afsd.

> And failure:

> [error] Starting AFS services: afsd
> afsd: too much mimsy in the borogroves

> Where start_daemon would do the funky output capture in a way that
> log_start_failure would then be able to use.

Yeah, that would be very useful.

This unfortunately still won't help in cases where the init script action
does something that causes kernel log output and that log output is
directed to the console (which is also a common case of weird output), but
that's much harder and probably not really feasible to fix.  And that can
cause problems no matter what the output format depending on timing.

-- 
Russ Allbery (rra@debian.org)               <http://www.eyrie.org/~eagle/>



Reply to: