PDA

View Full Version : Command line options for perl script



2003-12-25, 23:27
Is there a switch I can use to stop the server? Something along the lines of: ./slimserver.pl --stop

I'm using FreeBSD and want to write a script with start|stop options. Any help would be appreciated.

Oh, and it was implied but I'm using the perl 'version'.

Roy M. Silvernail
2003-12-25, 23:41
On Friday 26 December 2003 01:27, slimserve (AT) verizon (DOT) net wrote:
> Is there a switch I can use to stop the server? Something along the lines
> of: ./slimserver.pl --stop
>
> I'm using FreeBSD and want to write a script with start|stop options. Any
> help would be appreciated.

Does FreeBSD use a daemon controller? Gentoo uses start-stop-daemon. In any
case, it can be as easy as starting the server with

'--pidfile=/var/run/slimserver.pid'

in the command line and stopping it with

'kill `cat /var/run/slimserver.pid`'

Season the pidfile location to taste. Spelunk some of the other daemon
control scripts to get an idea of how FreeBSD customarily does it.

BTW, the above verbosity translates to "Nope, there's no stop flag." :)

Mark C. Langston
2003-12-25, 23:43
On Fri, Dec 26, 2003 at 12:27:19AM -0600, slimserve (AT) verizon (DOT) net wrote:
> Is there a switch I can use to stop the server? Something along the lines of: ./slimserver.pl --stop
>
> I'm using FreeBSD and want to write a script with start|stop options. Any help would be appreciated.
>
> Oh, and it was implied but I'm using the perl 'version'.
>


You can put the following into a file called "slimserver.sh" in
/usr/local/etc/rc.d, set perms to 755, and it'll start at boot, and you
can call it manually to start or stop the server.

---------------------------------------
#!/bin/sh

case "$1" in
start)
[ -x /usr/local/bin/slimerver] && /usr/local/bin/slimserver >
/dev/null && echo -n ' slimserver'
;;
stop)
/usr/bin/killall slimserver && echo "slimserver killed"
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
;;
esac

exit 0
---------------------------------------



--
Mark C. Langston Sr. Unix SysAdmin
mark (AT) bitshift (DOT) org mark (AT) seti (DOT) org
Systems & Network Admin SETI Institute
http://bitshift.org http://www.seti.org

Mark C. Langston
2003-12-26, 09:50
I actually prefer using logged PIDs rather than ambiguous killall or
pkill commands, so I've altered the script to use that approach:

---------------------------------------
#!/bin/sh

case "$1" in
start)
[ -x /usr/local/bin/slimerver] && /usr/local/bin/slimserver >
/dev/null && echo -n ' slimserver --pidfile=/var/run/slimserver.pid'
;;
stop)
/bin/kill `cat /var/run/slimserver.pid` && echo "slimserver killed"
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
;;
esac

exit 0
---------------------------------------



--
Mark C. Langston Sr. Unix SysAdmin
mark (AT) bitshift (DOT) org mark (AT) seti (DOT) org
Systems & Network Admin SETI Institute
http://bitshift.org http://www.seti.org

jimwillsher
2006-01-25, 15:02
Hi Mark,

Do you have an equivalent script which can be run on Ubuntu / Debian? There is no /usr/local/bin/slimserver (NB you put slimerver) command when it's compiled on Debian, it has to be started via /usr/local/slimserver/slimserver.pl

Starting it is fine, with a simple script as posted in these forums by others:

#!/bin/sh
echo "Starting SlimServer"
su - squeeze -c "cd /usr/local/slimserver; ./slimserver.pl --daemon"

But I can't find a graceful way to kill the server (which I have to do every few days when the web interface stops responding, as it used to do on RedHat - surprised the developers haven't encountered this themselves?)

Cheers,


Jim