Re: Question about rc-scripts

2007-10-09 Thread Mel
On Tuesday 09 October 2007 03:07:22 Stephen Allen wrote:
 Hi Derek,

  Not all scripts create a pid file is the simple answer.

 I didn't see how the isc-dhcpd script or dovecot created a pid, so I
 assumed it was something that rc.subr took care of.

  Your script should create the pid file on start, remove it on stop, and
  simply cat that file on a status.  If you want help with your script,
  post it, and I'm sure one of us will give you a hand.

 Again, I thought the rc.subr functions took care of all that for you
 (unless you wanted something special from those commands).

Creation of pid files isn't supported in /etc/rc.subr. It's a burdon of the 
application to do this for you, however, if your application doesn't do this, 
you can possibly use daemon(8) for the start_cmd, to create one for you.

This is however - quite up to the application. Some applications daemonize 
themselves by forking a child and detach the parent, in which case the pid 
file created by the daemon(8) command is useless, because it records the 
detached parent, not the running child.

On the other hand, pid files are a convenience, not a requirement for rc 
scripts. If no pidfile variable is defined, it will simply `killall $name`.

 I've posted the script (changed quite a lot from vendor supplied) at:
 http://www.pastebin.ca/730238

I'd make the start_cmd as follows:
start_cmd=${name}_start

dbgw_start()
{
echo Starting ${name}
/usr/bin/nice -5 /usr/sbin/daemon -p ${pidfile} ${command} \
${dbgw_flags} ${command_args}
}


-- 
Mel
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Question about rc-scripts

2007-10-09 Thread sdafreebsduk

Hi Philip,

Most binaries i.e. httpd, memcached, mysqld, etc... provide a config 
file or cli option to provide the path to a pid file.


Like you say - I can't find anything in rc.subr that would create a pid. 
 So, I looked in /etc/rc.d/ntpd (for example), and I still can't find 
in there where it might create a pid.


Your particular problem is that run_rc_command actually exits so that 
the script exits with the correct return code generally that of what 
the application in question returns from trying to start or stop.


Inless you have a reason, If you're running a daemon, you shouldn't need 
to background the command.


It /is/ a daemon


Also, rather then an echo try adding -x to the shebang line.


Yeah, I did that whilst I was re-arranging it.  I think my problem is, I 
don't understand properly what creates the pids for the standard scripts 
(like nptd), so I can't look at it to see how it's done.


Many thanks,
Steve
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Question about rc-scripts

2007-10-09 Thread Chuck Swiger

On Oct 9, 2007, at 5:16 PM, [EMAIL PROTECTED] wrote:
Most binaries i.e. httpd, memcached, mysqld, etc... provide a  
config file or cli option to provide the path to a pid file.


Like you say - I can't find anything in rc.subr that would create a  
pid.  So, I looked in /etc/rc.d/ntpd (for example), and I still  
can't find in there where it might create a pid.


In the case of ntpd, the default arguments look like this:

  /usr/sbin/ntpd -p /var/run/ntpd.pid ...

...so the ntpd process creates the pidfile.

--
-Chuck

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Question about rc-scripts

2007-10-08 Thread Stephen Allen

Under normal circumstance, should the /etc/rc.subr functions handle the
creation of the pid at service start?

The basic vendor-provided script (which I've had to adapt somewhat to
suit this installation) runs echo $!  ${dbgw_pidfile} as the last
line of the script.  When you do a 'status' command though, it blanks
out the contents of the pid.  That echo line isn't present in any of the
standard scripts - hence my initial question.

Apart from variable assignments, the script defines 'start_cmd' (which I
assume is used as the start command by rc.subr).  Strange that I
couldn't find any reference to start_cmd in /etc/rc.subr though.

So, my question is, why isn't the pidfile being automagically created?

Many thanks,
Steve

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Question about rc-scripts

2007-10-08 Thread Derek Ragona

At 05:45 PM 10/8/2007, Stephen Allen wrote:

Under normal circumstance, should the /etc/rc.subr functions handle the
creation of the pid at service start?

The basic vendor-provided script (which I've had to adapt somewhat to
suit this installation) runs echo $!  ${dbgw_pidfile} as the last
line of the script.  When you do a 'status' command though, it blanks
out the contents of the pid.  That echo line isn't present in any of the
standard scripts - hence my initial question.

Apart from variable assignments, the script defines 'start_cmd' (which I
assume is used as the start command by rc.subr).  Strange that I
couldn't find any reference to start_cmd in /etc/rc.subr though.

So, my question is, why isn't the pidfile being automagically created?

Many thanks,
Steve


Not all scripts create a pid file is the simple answer.

Your script should create the pid file on start, remove it on stop, and 
simply cat that file on a status.  If you want help with your script, post 
it, and I'm sure one of us will give you a hand.


-Derek

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Question about rc-scripts

2007-10-08 Thread Stephen Allen

Hi Derek,


Not all scripts create a pid file is the simple answer.


I didn't see how the isc-dhcpd script or dovecot created a pid, so I
assumed it was something that rc.subr took care of.

Your script should create the pid file on start, remove it on stop, and 
simply cat that file on a status.  If you want help with your script, 
post it, and I'm sure one of us will give you a hand.


Again, I thought the rc.subr functions took care of all that for you
(unless you wanted something special from those commands).

I've posted the script (changed quite a lot from vendor supplied) at:
http://www.pastebin.ca/730238

If you (or anyone) were to suggest changes, I would very much appreciate
the reasons why, so I can learn.

Many thanks,
Steve

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Question about rc-scripts

2007-10-08 Thread Philip M. Gollucci



Again, I thought the rc.subr functions took care of all that for you
(unless you wanted something special from those commands).
  

In general, they do
see /etc/rc.subr:
   check_pidfile(),
   wait_for_pids(),

Most binaries i.e. httpd, memcached, mysqld, etc... provide a config 
file or cli option to provide the path to a pid file.
If you look in the ports tree a lot of the patches are putting this in 
the appropriate location: /var/run


The rc.subr then just uses them.

In general this system is very flexible.  It breaks down if you wanted 
to run say 2 distinct memcached daemons on different ports with 
different pid files

via the /usr/local/etc/rc.d/script


I've posted the script (changed quite a lot from vendor supplied) at:
http://www.pastebin.ca/730238
  


Your particular problem is that run_rc_command actually exists so that 
the script exists with the correct return code generally that of what 
the application

in question returns from trying to start or stop.

Inless you have a reason, If you're running a daemon, you shouldn't need 
to background the command.


Also, rather then an echo try adding -x to the shebang line.



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Question about rc-scripts

2007-10-08 Thread Philip M. Gollucci

Philip M. Gollucci wrote:

Your particular problem is that run_rc_command actually exists so that
the script exists with the correct return code generally that of what
the application
in question returns from trying to start or stop.
  

s/exists/exits/g in the above.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]