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


  • callback <Function> 快照反序列化后作为入口点调用的回调。
  • data <any> 调用时将传给 callback 的可选数据。

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

  • callback <Function> Callback to be invoked as the entry point after the snapshot is deserialized.
  • data <any> Optional data that will be passed to the callback when it gets called.

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.