Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: add detailed embedder process initialization API #44121

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 13 additions & 7 deletions doc/api/embedding.md
Expand Up @@ -37,15 +37,18 @@ the `node` and `v8` C++ namespaces, respectively.
int main(int argc, char** argv) {
argv = uv_setup_args(argc, argv);
std::vector<std::string> args(argv, argv + argc);
std::vector<std::string> exec_args;
std::vector<std::string> errors;
// Parse Node.js CLI options, and print any errors that have occurred while
// trying to parse them.
int exit_code = node::InitializeNodeWithArgs(&args, &exec_args, &errors);
for (const std::string& error : errors)
std::unique_ptr<node::InitializationResult> result =
node::InitializeOncePerProcess(args, {
node::ProcessInitializationFlags::kNoInitializeV8,
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform
});

for (const std::string& error : result->errors())
fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str());
if (exit_code != 0) {
return exit_code;
if (result->early_return() != 0) {
return result->exit_code();
}

// Create a v8::Platform instance. `MultiIsolatePlatform::Create()` is a way
Expand All @@ -58,10 +61,13 @@ int main(int argc, char** argv) {
V8::Initialize();

// See below for the contents of this function.
int ret = RunNodeInstance(platform.get(), args, exec_args);
int ret = RunNodeInstance(
platform.get(), result->args(), result->exec_args());

V8::Dispose();
V8::DisposePlatform();

node::TearDownOncePerProcess();
return ret;
}
```
Expand Down