Register a function to be called at the beginning of the command loop.
777979
def register_preloop_hook(self, func: Callable[[None], None]) -> None:
        """"""
        self._validate_prepostloop_callable(func)
        self._preloop_hooks.append(func)
1320451
def _on_loop_start(self, variables):
        
        for callback in self.callbacks:
            if hasattr(callback, 'on_loop_start'):
                self.logs_[str(callback)].append(callback.on_loop_start(**variables))
228794
def run(self):
        """"""
        self.signal_init()
        self.listen_init()
        self.logger.info('starting')
        self.loop.start()
898228
protected function registerCommands()
    {
        collect($this->commandList)->each(function ($commandClass, $key) {
            $this->registerCommand($key, $commandClass);
        });
    }
74309
def register(self, cmd: Type[Command]) -> None:
        
        self.commands[cmd.command] = cmd
388661
def register_command(self, command):
		
		if(command.opcode() in self.commands_by_opcode):
			raise SetupError("Command with opcode {}(mnemonic: {}) already registered".format(command.opcode(), command.mnemonic()))
		command.membus = self.memory_bus
		command.devbus = self.device_bus
		command.register_interface = self.register_interface
		self.commands_by_opcode[command.opcode()] = command
239066
def add_cmd_handler(self, cmd, func):
        """"""
        len_args = len(inspect.getargspec(func)[0])

        def add_meta(f):
            def decorator(*args, **kwargs):
                f(*args, **kwargs)
            decorator.bytes_needed = len_args - 1  # exclude self
            decorator.__name__ = f.__name__
            return decorator
        func = add_meta(func)
        self._command_handlers[cmd] = func
1061480
private function register_commands() {
		foreach ( $this->commands as $class_name ) {
			\WP_CLI::add_command( $class_name::COMMAND_NAME, $class_name );
		}
	}
252864
def _start_io_loop(self):
        """"""

        def mark_as_ready():
            self._ready.set()

        if not self._io_loop:
            self._io_loop = ioloop.IOLoop()

        self._io_loop.add_callback(mark_as_ready)
        self._io_loop.start()
5446
def on_command_call(*args)
    if args.last && :args == args.last[0]
      args_add = args.pop
      call = on_call(*args)
      on_method_add_arg(call, args_add)
    else
      super
    end
  end
642112
def register(self, func):
        
        assert callable(func)
        assert inspect.getargspec(func).args == ["user", "privilege"]
        self.handlers.add(func)
1296815
def register(self, command: str, handler: Any):
        

        if not command.startswith("/"):
            command = f"/{command}"

        LOG.info("Registering %s to %s", command, handler)
        self._routes[command].append(handler)
930220
def add_command(self, func, name=None, doc=None):
        
        command = Command(func, doc)
        name = name or func.__name__
        self._commands[name] = command
125310
def post_register_hook(self, verbosity=1):
        """"""
        if not getattr(settings, 'FLOW_DOCKER_DONT_PULL', False):
            call_command('list_docker_images', pull=True, verbosity=verbosity)
270153
function register(server, options, next) {
	Schema.validate(options, function (error, config) {
		if (error) {
			next(error);
		} else {
			let methodsAsync = {};
			const dirs = config.methods;
			_.each(dirs, (dir) => {
				const relativePath = path.relative(__dirname, process.cwd() + '/' + dir);
				importDirectory(module, relativePath, {
					visit: function (obj) {
						if (!_.isUndefined(obj)) {
							let methods = _.isArray(obj) ? obj : [obj]; 
							_.each(methods, (method) => {
								if (_.isObject(method) && _.isFunction(method.method)) {
									const instance = _.clone(method);
									// store the oringial method
									const asyncMethod = method.method;
									// convert async function to normal thunky function
									instance.method = function (...args) {
										// the handler after function is called
										const after = args[args.length - 1];
										// call the async method, since asyn function return promise, use then and catch to handle result and error by handler
										asyncMethod.apply(this, args).then((result) => after(null, result)).catch((err) => after(err));
									};
									server.method(instance);
								}
							});
						}
					}
				});
			});
			_.each(server.methods, (method, name) => {
				methodsAsync[name] = function (...args) {
					// async function is a function return promise
					// convert back the async function
					return new Promise((resolve, reject) => {
						// call the thunky function
						server.methods[name].apply(server.methods, args.concat([(err, result) => {
							// reject if error exists, resolve if error not exists
							if (err) {
								reject(err);
							} else {
								resolve(result);
							}
						}]));
					});
				};
				// drop cache should also support async
				if (method.cache) {
					methodsAsync[name].cache = Promise.promisifyAll(method.cache);
				}
			});
			server.decorate('server', config.name, methodsAsync);
			next();
		}
	});
}
1329851
public void addStartCommand() {
        StringBuilder buf = new StringBuilder();
        buf.append("(start)");
        fifo.add(fifo.size(), buf.toString());
    }
594225
public static function initialize() {
        if (self::$registered) {
            debugging('Shutdown manager is already initialised!');
        }
        self::$registered = true;
        register_shutdown_function(array('core_shutdown_manager', 'shutdown_handler'));

        // Signal handlers should only be used when dealing with a CLI script.
        // In the case of PHP called in a web server the server is the owning process and should handle the signal chain
        // properly itself.
        // The 'pcntl' extension is optional and not available on Windows.
        if (CLI_SCRIPT && extension_loaded('pcntl') && function_exists('pcntl_async_signals')) {
            // We capture and handle SIGINT (Ctrl+C) and SIGTERM (termination requested).
            pcntl_async_signals(true);
            pcntl_signal(SIGINT, ['core_shutdown_manager', 'signal_handler']);
            pcntl_signal(SIGTERM, ['core_shutdown_manager', 'signal_handler']);
        }
    }