Re: Stop and start daemon
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=l+YvSimAPntD0nzX7nq6XzLVNXinhsk7omQm6jhGDE4=; b=EGZD/CvaFo8L8+rXVnHlF/qQLkFqtiL5okNg9fpbpmQjHQJBsFspGvnbzByOs5J5UX 6KN6msXvv+77xX8kEUv2ED4Q41Rd5r94KjdVWPTHymrYBPSu2iH7tRzrnoXF4Plj4VQa S+z5JqTvfCKGOh3lpB5HRNBJlkd6pJQuQZXOc= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=CJH4t7zp7eadHgNYiKkPkh9OEi2FLwXxkLkcatpnrTz6uuOHgBjP6ns6otgnJpJsmS osm3gILwMWzhn8ddMoeL4V8bm9aiZKDHuLqH0C8r465eOiS+Nua1LOMGwyJqxtj3GCIq fHH+IkOFeiGKJMPNK3hM+BIGT+oOX80SF55bY= Thanks. I would like to know one more thing that I do not want to create more one instance of my daemon but I can create more than one. So how to prevent to create more than one instance. Is it possible to have only one instance for all users? If yes then how. Regards On Mon, Jan 12, 2009 at 7:59 PM, Jason Coco <jason.coco@gmail.com> wrote:
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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Rakesh Singhal