worker.kill([signal])


  • signal <string> 发送给工作进程的终止信号的名称。默认值:'SIGTERM'

    ¥signal <string> Name of the kill signal to send to the worker process. Default: 'SIGTERM'

此函数会杀死工作进程。在主工作进程中,它通过断开 worker.process 来完成此操作,一旦断开连接,就使用 signal 终止。在工作进程中,它通过使用 signal 终止进程来实现。

¥This function will kill the worker. In the primary worker, it does this by disconnecting the worker.process, and once disconnected, killing with signal. In the worker, it does it by killing the process with signal.

kill() 函数在不等待正常断开连接的情况下杀死工作进程,它与 worker.process.kill() 具有相同的行为。

¥The kill() function kills the worker process without waiting for a graceful disconnect, it has the same behavior as worker.process.kill().

为了向后兼容,此方法别名为 worker.destroy()

¥This method is aliased as worker.destroy() for backwards compatibility.

在一个 worker 中,process.kill() 存在,但不是这个函数;它是 kill()

¥In a worker, process.kill() exists, but it is not this function; it is kill().