-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new main.rs, derived from bin/server.rs.
- Loading branch information
Showing
5 changed files
with
84 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
use clementine_core::database::Database; | ||
use clementine_core::servers::{ | ||
create_aggregator_grpc_server, create_operator_grpc_server, create_verifier_grpc_server, | ||
create_watchtower_grpc_server, | ||
}; | ||
use clementine_core::utils::get_configuration_for_binaries; | ||
use std::process::exit; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
eprintln!("\nBEWARE: Current behavior of this binary might be incorrect! It is in active development.\n"); | ||
|
||
let (mut config, args) = get_configuration_for_binaries(); | ||
|
||
if !args.verifier_server | ||
&& !args.operator_server | ||
&& !args.aggregator_server | ||
&& !args.watchtower_server | ||
{ | ||
eprintln!("No servers are specified. Please specify one."); | ||
exit(1); | ||
} | ||
|
||
Database::run_schema_script(&config) | ||
.await | ||
.expect("Can't run schema script"); | ||
|
||
let mut handles = vec![]; | ||
|
||
if args.verifier_server { | ||
handles.push( | ||
create_verifier_grpc_server(config.clone()) | ||
.await | ||
.expect("Can't create verifier server") | ||
.1, | ||
); | ||
config.port += 1; | ||
|
||
println!("Verifier server is started."); | ||
} | ||
|
||
if args.operator_server { | ||
handles.push( | ||
create_operator_grpc_server(config.clone()) | ||
.await | ||
.expect("Can't create operator server") | ||
.1, | ||
); | ||
config.port += 1; | ||
|
||
println!("Operator server is started."); | ||
} | ||
|
||
if args.aggregator_server { | ||
handles.push( | ||
create_aggregator_grpc_server(config.clone()) | ||
.await | ||
.expect("Can't create aggregator server") | ||
.1, | ||
); | ||
config.port += 1; | ||
|
||
println!("Aggregator server is started."); | ||
} | ||
|
||
if args.watchtower_server { | ||
handles.push( | ||
create_watchtower_grpc_server(config) | ||
.await | ||
.expect("Can't create watchtower server") | ||
.1, | ||
); | ||
|
||
println!("Watchtower server is started."); | ||
} | ||
|
||
// Wait for servers to close, A.K.A. run forever. | ||
for mut handle in handles { | ||
handle.closed().await; | ||
} | ||
} |