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

Improve boot related cli output #938

Merged
merged 8 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/psibase/native/include/psibase/ForkDb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ namespace psibase
try
{
if (bc->needGenesisAction)
trace.error = "Need genesis block; use 'psibase boot' to boot chain";
trace.error = "Node is not connected to any psibase network.";
else
{
check(trx.proofs.size() == trx.transaction->claims().size(),
Expand Down
2 changes: 1 addition & 1 deletion libraries/psibase_http/handle_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ namespace psibase::http
bc.start();
if (bc.needGenesisAction)
return send(error(bhttp::status::internal_server_error,
"Need genesis block; use 'psibase boot' to boot chain"));
"Node is not connected to any psibase network."));

SignedTransaction trx;
TransactionTrace trace;
Expand Down
55 changes: 47 additions & 8 deletions programs/psinode/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ bool pushTransaction(psibase::SharedState& sharedState,
try
{
if (bc.needGenesisAction)
trace.error = "Need genesis block; use 'psibase boot' to boot chain";
trace.error = "Node is not connected to any psibase network.";
else
{
check(trx.proofs.size() == trx.transaction->claims().size(),
Expand Down Expand Up @@ -2097,9 +2097,9 @@ void run(const std::string& db_path,
}
else
{
check(
false,
"should not get here, because service should have been checked already");
check(false,
"should not get here, because service should have been checked "
"already");
}
std::vector<Claim> claim;
result->get(claim);
Expand Down Expand Up @@ -2374,8 +2374,47 @@ void run(const std::string& db_path,
{
if (!showedBootMsg)
{
PSIBASE_LOG(node.chain().getLogger(), notice)
<< "Need genesis block; use 'psibase boot' to boot chain";
std::string xAdminSubdomain;
for (const auto& service : services)
{
if (service.root.string().find("services/x-admin") != std::string::npos &&
service.host.ends_with('.'))
{
xAdminSubdomain = service.host + host;
break;
}
}

if (!xAdminSubdomain.empty())
{
std::string protocol;
std::string port;
for (const auto& listen : http_config->listen)
{
if (const auto* spec =
std::get_if<psibase::http::tcp_listen_spec<true>>(&listen))
{
protocol = "https://";
port = std::to_string(spec->endpoint.port());
break;
}
else if (const auto* spec =
std::get_if<psibase::http::tcp_listen_spec<false>>(&listen))
{
protocol = "http://";
port = std::to_string(spec->endpoint.port());
}
}
xAdminSubdomain = protocol + xAdminSubdomain + ":" + port;
}

std::string message = "Node is not connected to any psibase network.";
if (!xAdminSubdomain.empty())
{
message += " Visit '" + xAdminSubdomain + "' for node setup.";
}

PSIBASE_LOG(node.chain().getLogger(), notice) << message;
showedBootMsg = true;
}
//continue;
Expand Down Expand Up @@ -2448,8 +2487,8 @@ int main(int argc, char* argv[])
"Controls client access to the admin API");
opt("database-cache-size",
po::value(&db_cache_size)->default_value({std::size_t(1) << 33}, "8 GiB"),
"The amount of RAM reserved for the database cache. Must be at least 64 MiB. Warning: this "
"will not modify an existing database. This option is subject to change.");
"The amount of RAM reserved for the database cache. Must be at least 64 MiB. Warning: "
"this will not modify an existing database. This option is subject to change.");
#ifdef PSIBASE_ENABLE_SSL
opt("tls-trustfile", po::value(&root_ca)->default_value({}, "")->value_name("path"),
"A list of trusted Certification Authorities in PEM format");
Expand Down
2 changes: 1 addition & 1 deletion programs/psitest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ struct callbacks

psibase::BlockContext bc{*chain.sys, chain.head, chain.writer, true};
bc.start();
psibase::check(!bc.needGenesisAction, "Need genesis block; use 'psibase boot' to boot chain");
psibase::check(!bc.needGenesisAction, "Node is not connected to any psibase network.");
psibase::SignedTransaction trx;
psibase::TransactionContext tc{bc, trx, trace, true, false, true};

Expand Down
5 changes: 3 additions & 2 deletions rust/psibase/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,9 @@ async fn boot(args: &BootArgs) -> Result<(), anyhow::Error> {
.await?;
progress.inc(1)
}

if !args.tx_args.suppress_ok {
println!("Ok");
println!("Successfully booted {}", args.node_args.api);
}
Ok(())
}
Expand Down Expand Up @@ -1257,7 +1258,7 @@ fn handle_unbooted(list: Result<PackageList, anyhow::Error>) -> Result<PackageLi
if let Err(e) = &list {
if e.root_cause()
.to_string()
.contains("Need genesis block; use 'psibase boot' to boot chain")
.contains("Node is not connected to any psibase network.")
{
return Ok(PackageList::new());
}
Expand Down
Loading