Re: Stop and start daemon
Re: Stop and start daemon
- Subject: Re: Stop and start daemon
- From: "Rakesh Singhal" <email@hidden>
- Date: Tue, 13 Jan 2009 14:21:33 +0530
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 <email@hidden> 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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden