Ship commands to the daemon.
199060
def send(self, commands):
        ""
        if not commands.endswith("\n"):
            commands += "\n"
        self.sock.send(commands)
891878
def start(self, daemon=True):
        
        if self._run_lock.acquire(False):
            try:
                # there is a short race window in which `start` release the lock,
                # but `run` has not picked it up yet, but the thread exists anyway
                if self._run_thread is None:
                    self._run_thread = threading.Thread(target=self._run_in_thread)
                    self._run_thread.daemon = daemon
                    self._run_thread.start()
            finally:
                self._run_lock.release()
1268761
def send_command(self, data, read_delay=None):
        """"""
        self._write(data)
        if read_delay:
            time.sleep(read_delay)
        return self._read()
441980
def manage_daemon(self):
        
        while not self.shutdown:
            # next scheduled daemon, tuple (time, index)
            item = self.daemon_list.get_next_item()
            cur = time.time()
            pajama_time = item[0] - cur
            if pajama_time > 0:
                self.thread_event.wait(pajama_time)
            if not self.shutdown:
                self.start_crawler(item[1], daemonize=True)
732882
def start
      puts "== Connected to #{redis.client.id}"
      puts "== Waiting for commands from `#{options[:queue]}`"
      
      if options[:daemon]
        puts "== Daemonizing..."
        Daemons.daemonize
      end
      
      loop do
        begin 
          cid = redis.blpop(options[:queue], 10)[1]
          if cmd = commands[cid.to_s]
            puts "\e[33m[#{Time.now}]\e[0m Reacting for `#{cid}` command"
            threads.add(Thread.new { system(cmd) })
          end
        rescue Interrupt, SystemExit
          puts "\nCleaning up..."
          return 0
        rescue => ex
          puts "ERROR: #{ex}"
        end
      end
    end
1068018
function processCommandLine() {
        if (commander.list) {
            listApps();
            process.exit(0);
        }

        if (!commander.app) {
            commander.help();
        }

        commander.endDate = commander.runDate ? moment(commander.runDate, 'MM/DD/YYYY').toDate() : new Date();
        commander.startDate = moment(commander.endDate).subtract(commander.runDays, 'days').toDate();
        commander.startDate.setHours(0, 0, 0, 0);
    }
1241294
def main():
    
    (options, _) = _parse_args()

    if options.change_password:
        c.keyring_set_password(c["username"])
        sys.exit(0)

    if options.select:
        courses = client.get_courses()
        c.selection_dialog(courses)
        c.save()
        sys.exit(0)

    if options.stop:
        os.system("kill -2 `cat ~/.studdp/studdp.pid`")
        sys.exit(0)

    task = _MainLoop(options.daemonize, options.update_courses)

    if options.daemonize:
        log.info("daemonizing...")
        with daemon.DaemonContext(working_directory=".", pidfile=PIDLockFile(PID_FILE)):
            # we have to create a new logger in the daemon context
            handler = logging.FileHandler(LOG_PATH)
            handler.setFormatter('%(asctime)s [%(levelname)s] %(name)s: %(message)s')
            log.addHandler(handler)
            task()
    else:
        task()
607089
def run(self):
        '''
        
        '''
        salt.utils.process.appendproctitle(self.__class__.__name__)

        # init things that need to be done after the process is forked
        self._post_fork_init()

        # Make Start Times
        last = int(time.time())

        old_present = set()
        while True:
            now = int(time.time())
            if (now - last) >= self.loop_interval:
                salt.daemons.masterapi.clean_old_jobs(self.opts)
                salt.daemons.masterapi.clean_expired_tokens(self.opts)
                salt.daemons.masterapi.clean_pub_auth(self.opts)
                salt.daemons.masterapi.clean_proc_dir(self.opts)
            self.handle_git_pillar()
            self.handle_schedule()
            self.handle_key_cache()
            self.handle_presence(old_present)
            self.handle_key_rotate(now)
            salt.utils.verify.check_max_open_files(self.opts)
            last = now
            time.sleep(self.loop_interval)
416627
def create_process(daemon, name, callback, *callbackParams):
    
    bp = Process(daemon=daemon, name=name, target=callback, args=callbackParams)
    return bp
74704
def spawn_thread(self):
        ''
        self.thread = threading.Thread(target=self.run, args=(False,))
        self.thread.daemon = True
        self.thread.start()
1167300
def _daemon_thread(*a, **kw):
    
    thread = Thread(*a, **kw)
    thread.daemon = True
    return thread
1353920
def daemonize(self):
        """"""
        self._double_fork()

        # Write pidfile.
        self.pid = os.getpid()

        LOG.info(
            "Succesfully daemonized process {0}.".format(self.pid)
        )
714199
def execute(opts, data, func, args, kwargs):
    '''
    
    '''
    if data['fun'] == 'saltutil.find_job':
        return __executors__['direct_call.execute'](opts, data, func, args, kwargs)
    if data['fun'] in DOCKER_MOD_MAP:
        return __executors__['direct_call.execute'](opts, data, __salt__[DOCKER_MOD_MAP[data['fun']]], [opts['proxy']['name']] + args, kwargs)
    return __salt__['docker.call'](opts['proxy']['name'], data['fun'], *args, **kwargs)
1318131
def sendCMD (self, vel):
        '''
        

        '''
        self.lock.acquire()
        self.vel = vel
        self.lock.release()
836597
def launch(self):
    
    self.terminate(include_watchman=False)
    self.watchman_launcher.maybe_launch()
    self._logger.debug('launching pantsd')
    self.daemon_spawn()
    # Wait up to 60 seconds for pantsd to write its pidfile.
    pantsd_pid = self.await_pid(60)
    listening_port = self.read_named_socket('pailgun', int)
    self._logger.debug('pantsd is running at pid {}, pailgun port is {}'
                       .format(self.pid, listening_port))
    return self.Handle(pantsd_pid, listening_port, text_type(self._metadata_base_dir))
1327954
def cmd(commands, opts={})
      results = {}
      threads = clouds.collect do |name, c|
        Thread.new{ results[ name ] = c.cmd(commands, opts) }
      end
      threads.each{ |aThread| aThread.join }
      results
    end
1116
function commander (options) {
    const { cmds, version } = options
    const argvs = parseArgs()
    if (argvs._.length === 0) {
        if (argvs.v || argvs.version) {
            process.stdout.write(version + '\n' || 'unknow\n')
            process.exit()
        } else {
            help(options)
        }
    } else {
        const cmd = cmds.filter(function (v) {
            return v.command === argvs._[0] || v.aliases === argvs._[0]
        })[0]
        
        if (!cmd) {
            help(options)
        }
        cmd.module.handler(argvs)
    }
}