On Mon, 2008-01-28 at 16:23 -0500, Chris AtLee wrote:
> Hello Pyloneers,
>
> For one of the applications I'm writing, it would be really handy to
> have the app advertise itself with avahi so that clients on the
> network could automatically find it.
>
> What I've got so far is the following, which has been added to
> Globals.__init__:
>
> publishInfo = config.get("publish_url") # e.g.
> http://hostname.mydomain.com:5002
> if publishInfo:
> appname = config.get("package")
> s = urlparse.urlparse(publishInfo)
> hostname = s.hostname
> port = str(s.port)
> url = s.path
> args = ["avahi-publish-service", appname, "_%s._tcp" %
> appname, port]
> if url:
> args.append(url)
>
> try:
> self.avahiRegistration = subprocess.Popen(args,
> close_fds=True)
> except OSError:
> log.warning("Couldn't start avahi-publish-service")
>
> This kind of works...The problem so far is that when the application
> is run under paste with the --reload option, the child
> avahi-publish-service processes don't get killed off when the
> application is shutdown. When paster restarts the application, the
> old avahi process is re-parented to the init process. The same
> problem occurs when running with --daemon.
Have you tried using the Avahi Python bindings? I'd expect that to work
far better than opening a subprocess.
Regards,
Cliff
> Is there a way to get notified when your application is about to be
> shut down? Paste looks like it just sends SIGTERM to the process when
> it detects a modified file, but maybe I'm missing something.
>
> Maybe there's a better approach I could be taking?
>
> Thanks!
> Chris
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---