v8.startupSnapshot.setDeserializeMainFunction(callback[, data])


  • callback <Function> 快照反序列化后调用的入口回调。
  • data <any> 可选数据,在调用 callback 时会传递给它。

这设置了 Node.js 应用在从快照反序列化时的入口点。该函数只能在构建快照的脚本中调用一次。调用后,反序列化后的应用不再需要额外的入口脚本来启动,并会直接调用回调函数及反序列化的数据(如果提供的话),否则仍需要向反序列化的应用提供入口脚本。

【This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script. If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.】