def ensure_running( config ): """ Verify that there is an automount daemon servicing a mountpoint. If there isn't, start one. If we're configured to run in the foreground, this method never returns. """ mountpoint_dir = config['mountpoint_dir'] # is the daemon running? procs = watchdog.find_by_attrs( "syndicate-automount-daemon", {"mounts": mountpoint_dir} ) if len(procs) > 0: # it's running print "Syndicate automount daemon already running for %s (PID(s): %s)" % (mountpoint_dir, ",".join( [str(watchdog.get_proc_pid(p)) for p in procs] )) return True if config.get("foreground", None): main( config ) else: logfile_path = None pidfile_path = config.get("pidfile", None) if config.has_key("logdir"): logfile_path = os.path.join( config['logdir'], "syndicated.log" ) title = watchdog.attr_proc_title( "syndicate-automount-daemon", {"mounts" : mountpoint_dir} ) setproctitle.setproctitle( title ) daemon.daemonize( lambda: main(config), logfile_path=logfile_path, pidfile_path=pidfile_path ) return True
# not running, and not foregrounding. fork a new one try: watchdog_pid = os.fork() except OSError, oe: logger.error("Failed to fork, errno = %s" % oe.errno) return False if watchdog_pid != 0: # child--become watchdog setproctitle.setproctitle("syndicate-credential-server-watchdog") if run_once: syndicate_daemon.daemonize(lambda: credential_server_spawn(0), logfile_path=getattr( CONFIG, "SYNDICATE_HTTP_LOGFILE", None)) else: syndicate_daemon.daemonize(lambda: syndicate_watchdog.main( credential_server_spawn, respawn_exit_statuses=range(1, 254)), logfile_path=getattr( CONFIG, "SYNDICATE_HTTP_LOGFILE", None)) #------------------------------- # Begin functional tests. # Any method starting with ft_ is a functional test. #-------------------------------
# not running, and not foregrounding. fork a new one try: watchdog_pid = os.fork() except OSError, oe: logger.error("Failed to fork, errno = %s" % oe.errno) return False if watchdog_pid != 0: # child--become watchdog setproctitle.setproctitle( "syndicate-credential-server-watchdog" ) if run_once: syndicate_daemon.daemonize( lambda: credential_server_spawn(0), logfile_path=getattr(CONFIG, "SYNDICATE_HTTP_LOGFILE", None) ) else: syndicate_daemon.daemonize( lambda: syndicate_watchdog.main( credential_server_spawn, respawn_exit_statuses=range(1,254) ), logfile_path=getattr(CONFIG, "SYNDICATE_HTTP_LOGFILE", None) ) #------------------------------- # Begin functional tests. # Any method starting with ft_ is a functional test. #------------------------------- #------------------------------- def ft_syndicate_access(): """ Functional tests for ensuring objects exist and don't exist in Syndicate. """