Re: [lfs-dev] lfs bootscripts and multiple instances

2012-02-03 Thread Bruce Dubbs
de...@hawaii.rr.com wrote:
> Bruce Dubbs wrote:
>>> BTW: statusproc() defined in /lib/lsb/init-functions has an "exit 1" just 
>>> after
>>> it prints its Usage statement; shouldn't this be a "return 1" instead?
>> statusproc is a function to print out a nicely formatted status message
>>from the results of pidofproc. It was designed to be used in an
>> initialization script as in './script status'  If you give it the wrong
>> parameters, then that script should start.  If you want to use the info
>> and do error handling, use pidofproc instead.
> 
> If that's how it's meant to be used (I presume you meant "script should
> stop") then that makes sense.  

Yes, I did mean stop.

> It's an oddball function though - the 
> only one in /lib/lsb/init-functions that prints a usage statement and 
> the only one that exits instead of returning an error code - which led 
> to the confusing (to me anyway) situation where using it on the command 
> line with incorrect/missing options prints a usage statement followed
> immediately by terminating your login shell.

It's a convenience function for the boot scripts.  Always been that way 
AFAIK.

>> statusproc just uses what is returned from pidofproc.  Since you are 
> 
> Aha!  After the argument processing loop in statusproc(), the logic in the
> test for the pidfile name is backward; the pidfile argument to statusproc
> never gets passed on to pidofproc():
> 
> (lfs-bootscripts-20120116/lfs/lib/services/init-functions line 513-517)
> 
> if [ -z "${pidfile}" ]; then
>pidlist=`pidofproc -p "${pidfile}" $@`
> else
>pidlist=`pidofproc $@`
> fi

OK, change -z to -n

   -- Bruce
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page


Re: [lfs-dev] lfs bootscripts and multiple instances

2012-02-03 Thread deant

Bruce Dubbs wrote:
>> BTW: statusproc() defined in /lib/lsb/init-functions has an "exit 1" just 
>> after
>> it prints its Usage statement; shouldn't this be a "return 1" instead?
>
>statusproc is a function to print out a nicely formatted status message
>from the results of pidofproc. It was designed to be used in an
>initialization script as in './script status'  If you give it the wrong
>parameters, then that script should start.  If you want to use the info
>and do error handling, use pidofproc instead.

If that's how it's meant to be used (I presume you meant "script should
stop") then that makes sense.  It's an oddball function though - the 
only one in /lib/lsb/init-functions that prints a usage statement and 
the only one that exits instead of returning an error code - which led 
to the confusing (to me anyway) situation where using it on the command 
line with incorrect/missing options prints a usage statement followed
immediately by terminating your login shell.


>statusproc just uses what is returned from pidofproc.  Since you are 

Aha!  After the argument processing loop in statusproc(), the logic in the
test for the pidfile name is backward; the pidfile argument to statusproc
never gets passed on to pidofproc():

(lfs-bootscripts-20120116/lfs/lib/services/init-functions line 513-517)

if [ -z "${pidfile}" ]; then
   pidlist=`pidofproc -p "${pidfile}" $@`
else
   pidlist=`pidofproc $@`
fi


-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page


Re: [lfs-dev] lfs bootscripts and multiple instances

2012-02-03 Thread Bruce Dubbs
Dean Takemori wrote:
> I'm trying to setup multiple instances of rsyslog (one for kernel
> messages) using lfs-bootscripts-20120116 and running into some
> problems.
> 
> I'm using rsyslogd 5.8.6, which is designed with multiple instance
> support.  I've set up one configuration file (/etc/rsysklog.conf) 
> for the kernel logger and one for the system logger (/etc/rsyslog.conf)
> 
> rsyslogd's 
>   -i flag specifies the pid file used and
>   -f specifies the configuration file.
> 
>> root:~# source /lib/lsb/init-functions
>>
>> root:~# start_daemon -p /run/rsyslogd.pid /sbin/rsyslogd -i 
>> /run/rsyslogd.pid -f /etc/rsyslog.conf
>> root:~# echo $?
>> 0
> 
> Now let's check:
> 
>> root:~# ps xa | grep rsyslogd
>> 8045 ?Sl   0:00 /sbin/rsyslogd -i /run/rsyslogd/pid -f 
>> /etc/rsyslog.conf
>> 8131 tty1 s+   0:00 grep rsyslog
>>
>> root:~# stausproc -p /run/rsyslogd.pid /rsbin/rsyslogd
>> rsyslogd is running with Process ID(s) 8045
>>
>> root:# cat /run/rsyslogd.pid
>> 8045
> 
> So far so good.
> 
> But now let's try running the second instance.
> 
>> root:~# start_daemon -p /run/rsysklogd.pid /sbin/rsyslogd -i 
>> /run/rsysklogd.pid -f /etc/rsysklog.conf
>> root:~# echo $?
>> 0
> 
> and now check:
>> root:~# ps xa | grep rsyslogd
>>  8045 ?Sl   0:00 /sbin/rsyslogd -i /run/rsyslogd.pid -f 
>> /etc/rsyslog.conf
>> 8133 tty1 s+   0:00 grep rsyslog
> 
> 
> What?
> 
> Note that rsyslog behaves as expected:
> 
>> root:~# sbin/rsyslogd -i /run/rsysklogd.pid -f /etc/rsysklog.conf
>> root:~# echo $?
>> 0
>>
>> root:~# ps xa | grep rsyslogd
>> 8045 ?Sl   0:00 /sbin/rsyslogd -i /run/rsyslogd.pid -f 
>> /etc/rsyslog.conf
>> 8149 ?Sl   0:00 /sbin/rsyslogd -i /run/rsysklogd.pid -f 
>> /etc/rsysklog.conf
>> 8155 tty1 s+   0:00 grep rsyslog
>>
>> root:~# cat /run/rsyslogd.pid
>> 8045
>> root:~# cat /run/rsysklogd.pid
>> 8149
> 
> 
> So far, I think I've tracked the problem down to statusproc() not correctly
> using the pidfile it's given.
> 
> Namely: this is correct
> 
>> root:~# statusproc -p /run/rsyslogd.pid /sbin/rsyslogd
>> rsyslogd is running with Process ID(s) 8045
>>
>> root:~# cat /run/rsyslogd.pid
>> 8045
> 
> But this is not
>> root:~# statusproc -p /run/rsysklogd.pid /sbin/rsyslogd
>> rsyslogd is running with Process ID(s) 8045
>>
>> root:~# cat /run/rsysklogd.pid
>> 8149

statusproc just uses what is returned from pidofproc.  Since you are 
specifying a pidfile, pidofproc is doing:

pidlist=`/bin/head -n1 "${pidfile}"`

It then checks to see if the pids in pidlist are running.
In line 460, we have:

  lpids="${pids}${pid} "

but pids is never defined.  Try changing that line to

  lpids="${lpids}${pid} "

and see if that makes a difference.  If that doesn't help, throw in a 
few echo or cat statements at the right places to see what it going on. 
  If you identify another problem, we'll certainly address it.

> BTW: statusproc() defined in /lib/lsb/init-functions has an "exit 1" just 
> after
> it prints its Usage statement; shouldn't this be a "return 1" instead?

statusproc is a function to print out a nicely formatted status message
from the results of pidofproc. It was designed to be used in an
initialization script as in './script status'  If you give it the wrong
parameters, then that script should start.  If you want to use the info
and do error handling, use pidofproc instead.

> BTW2: statusproc()'s Usage statement says :
>   echo "Usage: [-p pidfile] statusproc {program}"
> Shouldn't this be this?
>   echo "Usage: statusproc [-p pidfile] {program}"

I've fixed this in my sandbox.  It will be updated at the next commit.

   -- Bruce
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page


Re: [lfs-dev] lfs bootscripts and multiple instances

2012-02-03 Thread DJ Lucas
On 02/03/2012 01:55 AM, Dean Takemori wrote:
> I'm trying to setup multiple instances of rsyslog (one for kernel
> messages) using lfs-bootscripts-20120116 and running into some
> problems.
>
> I'm using rsyslogd 5.8.6, which is designed with multiple instance
> support.  I've set up one configuration file (/etc/rsysklog.conf)
> for the kernel logger and one for the system logger (/etc/rsyslog.conf)
>
> rsyslogd's
>   -i flag specifies the pid file used and
>   -f specifies the configuration file.
>
>> root:~# source /lib/lsb/init-functions
>>
>> root:~# start_daemon -p /run/rsyslogd.pid /sbin/rsyslogd -i 
>> /run/rsyslogd.pid -f /etc/rsyslog.conf
>> root:~# echo $?
>> 0
> Now let's check:
>
>> root:~# ps xa | grep rsyslogd
>> 8045 ?Sl   0:00 /sbin/rsyslogd -i /run/rsyslogd/pid -f 
>> /etc/rsyslog.conf
>> 8131 tty1 s+   0:00 grep rsyslog
>>
>> root:~# stausproc -p /run/rsyslogd.pid /rsbin/rsyslogd
>> rsyslogd is running with Process ID(s) 8045
>>
>> root:# cat /run/rsyslogd.pid
>> 8045
> So far so good.
>
> But now let's try running the second instance.
>
>> root:~# start_daemon -p /run/rsysklogd.pid /sbin/rsyslogd -i 
>> /run/rsysklogd.pid -f /etc/rsysklog.conf
>> root:~# echo $?
>> 0
> and now check:
>> root:~# ps xa | grep rsyslogd
>>   8045 ?Sl   0:00 /sbin/rsyslogd -i /run/rsyslogd.pid -f 
>> /etc/rsyslog.conf
>> 8133 tty1 s+   0:00 grep rsyslog
>
> What?
>
> Note that rsyslog behaves as expected:
>
>> root:~# sbin/rsyslogd -i /run/rsysklogd.pid -f /etc/rsysklog.conf
>> root:~# echo $?
>> 0
>>
>> root:~# ps xa | grep rsyslogd
>> 8045 ?Sl   0:00 /sbin/rsyslogd -i /run/rsyslogd.pid -f 
>> /etc/rsyslog.conf
>> 8149 ?Sl   0:00 /sbin/rsyslogd -i /run/rsysklogd.pid -f 
>> /etc/rsysklog.conf
>> 8155 tty1 s+   0:00 grep rsyslog
>>
>> root:~# cat /run/rsyslogd.pid
>> 8045
>> root:~# cat /run/rsysklogd.pid
>> 8149
>
> So far, I think I've tracked the problem down to statusproc() not correctly
> using the pidfile it's given.
>
> Namely: this is correct
>
>> root:~# statusproc -p /run/rsyslogd.pid /sbin/rsyslogd
>> rsyslogd is running with Process ID(s) 8045
>>
>> root:~# cat /run/rsyslogd.pid
>> 8045
> But this is not
>> root:~# statusproc -p /run/rsysklogd.pid /sbin/rsyslogd
>> rsyslogd is running with Process ID(s) 8045
>>
>> root:~# cat /run/rsysklogd.pid
>> 8149
>
>
>
> BTW: statusproc() defined in /lib/lsb/init-functions has an "exit 1" just 
> after
> it prints its Usage statement; shouldn't this be a "return 1" instead?
>
> BTW2: statusproc()'s Usage statement says :
>   echo "Usage: [-p pidfile] statusproc {program}"
> Shouldn't this be this?
>   echo "Usage: statusproc [-p pidfile] {program}"
Yes, statusproc() looks broken. Might it be better to use pidofproc() 
directly where possible? Not sure that statusproc() should be needed any 
longer. I haven't had the time to dig too deep into the wrapper 
functions since the rewrite. I'll have a look at them later today, but 
hopefully Bruce can chime in here today as well. Not sure about the exit 
vs return.

-- DJ Lucas


-- 
This message has been scanned for viruses and
dangerous content, and is believed to be clean.

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page


[lfs-dev] lfs bootscripts and multiple instances

2012-02-02 Thread Dean Takemori
I'm trying to setup multiple instances of rsyslog (one for kernel
messages) using lfs-bootscripts-20120116 and running into some
problems.

I'm using rsyslogd 5.8.6, which is designed with multiple instance
support.  I've set up one configuration file (/etc/rsysklog.conf) 
for the kernel logger and one for the system logger (/etc/rsyslog.conf)

rsyslogd's 
-i flag specifies the pid file used and
-f specifies the configuration file.

> root:~# source /lib/lsb/init-functions
> 
> root:~# start_daemon -p /run/rsyslogd.pid /sbin/rsyslogd -i /run/rsyslogd.pid 
> -f /etc/rsyslog.conf
> root:~# echo $?
> 0

Now let's check:

> root:~# ps xa | grep rsyslogd
> 8045 ?Sl   0:00 /sbin/rsyslogd -i /run/rsyslogd/pid -f 
> /etc/rsyslog.conf
> 8131 tty1 s+   0:00 grep rsyslog
> 
> root:~# stausproc -p /run/rsyslogd.pid /rsbin/rsyslogd
> rsyslogd is running with Process ID(s) 8045
> 
> root:# cat /run/rsyslogd.pid
> 8045

So far so good.

But now let's try running the second instance.

> root:~# start_daemon -p /run/rsysklogd.pid /sbin/rsyslogd -i 
> /run/rsysklogd.pid -f /etc/rsysklog.conf
> root:~# echo $?
> 0

and now check:
> root:~# ps xa | grep rsyslogd
>  8045 ?Sl   0:00 /sbin/rsyslogd -i /run/rsyslogd.pid -f 
> /etc/rsyslog.conf
> 8133 tty1 s+   0:00 grep rsyslog


What?

Note that rsyslog behaves as expected:

> root:~# sbin/rsyslogd -i /run/rsysklogd.pid -f /etc/rsysklog.conf
> root:~# echo $?
> 0
>
> root:~# ps xa | grep rsyslogd
> 8045 ?Sl   0:00 /sbin/rsyslogd -i /run/rsyslogd.pid -f 
> /etc/rsyslog.conf
> 8149 ?Sl   0:00 /sbin/rsyslogd -i /run/rsysklogd.pid -f 
> /etc/rsysklog.conf
> 8155 tty1 s+   0:00 grep rsyslog
>
> root:~# cat /run/rsyslogd.pid
> 8045
> root:~# cat /run/rsysklogd.pid
> 8149


So far, I think I've tracked the problem down to statusproc() not correctly
using the pidfile it's given.

Namely: this is correct

> root:~# statusproc -p /run/rsyslogd.pid /sbin/rsyslogd
> rsyslogd is running with Process ID(s) 8045
>
> root:~# cat /run/rsyslogd.pid
> 8045

But this is not
> root:~# statusproc -p /run/rsysklogd.pid /sbin/rsyslogd
> rsyslogd is running with Process ID(s) 8045
>
> root:~# cat /run/rsysklogd.pid
> 8149




BTW: statusproc() defined in /lib/lsb/init-functions has an "exit 1" just after
it prints its Usage statement; shouldn't this be a "return 1" instead?

BTW2: statusproc()'s Usage statement says :
echo "Usage: [-p pidfile] statusproc {program}"
Shouldn't this be this?
echo "Usage: statusproc [-p pidfile] {program}"
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page