Re: Stop and start daemon
Re: Stop and start daemon
- Subject: Re: Stop and start daemon
- From: Jason Coco <email@hidden>
- Date: Mon, 12 Jan 2009 09:29:44 -0500
On Jan 12, 2009, at 08:55 , Rakesh Singhal wrote:
Hi Jason,
Thanks but I knew this thing. Is there any other way to do the same
thing only on the basis of name of daemon application.
I think we can not do even by using StartupItems.
Using the dot notation for your daemon is just the suggested form
(although it's suggested for a good reason). You can use whatever
label you wish. Just make the label in the plist the same as the name
of the daemon and then you can start and stop it using just the
daemon's name.
launchctl start mydaemon
launchctl stop mydaemon
That's basically the way it's done. If you want to give users
something else to start and stop the daemon, you can create a simple
script that calls launchctl. For example:
#!/bin/bash
case "$1" in
start)
/bin/launchctl start com.mycompany.mydaemon.daemon # use whatever
label is in the plist
;;
stop)
/bin/launchctl stop com.mycompany.mydaemon.daemon
;;
restart)
/bin/launchctl stop com.mycompany.mydaemon.daemon
;;
status)
if (/bin/launchctl list | grep com.mycompany.mydaemon.daemon >/
dev/null); then
echo Daemon is running
else
echo Daemon is not running
fi
;;
*)
echo "Usage $0 { stop|start|restart|status }
exit 1
esac
You can also write an application which uses the launchd api to
programatically start and stop the daemon. This way you could write a
little gui app to control it or a system panel to toggle it on or off.
If you wish to do it this way, see the API in /usr/include/launch.h
HTH, Jason
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden