"Jason R. Mastaler" <[EMAIL PROTECTED]> writes: > Tim Legant <[EMAIL PROTECTED]> writes: > >> + except OSError, e: >> + if e.errno == errno.EEXIST: >> + msg = "File '%s' already exists. Another copy of tmda-" \ >> + "ofmipd is already running or a previous run of " \ >> + "tmda-ofmipd aborted, leaving the file. Either " \ >> + "remove '%s' by hand or use the --pidfile flag to " \ >> + "specify a different file in which to store the " \ >> + "PID." % (pidfile, pidfile) >> + warning(msg) > > Do you think this is the right thing to do? Most daemons seem to just > overwrite an existing pid file when started. In the case of multiple > daemons running on different ports, the pid file just reflects the > process ID of the one started last.
Hm. I based this idea on PostgreSQL, which will refuse to start a second instance if a pid file exists. The pid file is maintained in a directory relative to the database files, though, rather than in /var/run, so multiple instances of Postgres can be run, just not on the same database. As Lloyd and Cory both point out though, running multiple instances of tmda-ofmipd can be desirable. Given that tmda-ofmipd doesn't have a natural "data" directory, /var/run seems the best place for the pid file (unless the user specifies otherwise, of course). Coupled with the desire for multiple instances, the pid file should probably reflect the port number: /var/run/tmda-ofmipd:8025.pid or something similar. My current version of the patch cleans up the pid file on termination, so the only reason that a pid file would exist is if the daemon aborted. A warning of some sort seems in order, but perhaps the warning should simply be printed and then the existing pid file should be overwritten. If an instance is already running on the same port, tmda-ofmipd will already have abended with a traceback about not being able to bind the port, since that occurs before we try to create the pid file. Does this behavior (print warning, but continue) make more sense? Tim _________________________________________________ tmda-workers mailing list ([EMAIL PROTECTED]) http://tmda.net/lists/listinfo/tmda-workers
