forked from matter-labs/zksync
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -1,29 +1,36 @@ | ||
extern crate storage; | ||
extern crate prover; | ||
extern crate signal_hook; | ||
extern crate tokio; | ||
extern crate futures; | ||
|
||
use std::sync::atomic::{AtomicBool, Ordering}; | ||
use std::sync::Arc; | ||
use std::thread; | ||
use std::time::Duration; | ||
use std::sync::{Arc, atomic::{AtomicBool}}; | ||
use std::env; | ||
|
||
use prover::start_prover; | ||
use prover::run_prover; | ||
use signal_hook::iterator::Signals; | ||
use futures::Stream; | ||
|
||
fn main() { | ||
|
||
let mut rt = tokio::runtime::Runtime::new().unwrap(); | ||
|
||
// handle ctrl+c | ||
let stop_signal = Arc::new(AtomicBool::new(false)); | ||
signal_hook::flag::register(signal_hook::SIGTERM, Arc::clone(&stop_signal)).expect("Error setting SIGTERM handler"); | ||
signal_hook::flag::register(signal_hook::SIGINT, Arc::clone(&stop_signal)).expect("Error setting SIGINT handler"); | ||
signal_hook::flag::register(signal_hook::SIGQUIT, Arc::clone(&stop_signal)).expect("Error setting SIGQUIT handler"); | ||
|
||
let args: Vec<String> = env::args().collect(); | ||
start_prover(args.get(1).unwrap_or(&"default".to_string()).clone()); | ||
rt.spawn( | ||
Signals::new(&[signal_hook::SIGTERM, signal_hook::SIGINT, signal_hook::SIGQUIT]) | ||
.unwrap() | ||
.into_async() | ||
.unwrap() | ||
.map_err(|_|()) | ||
.for_each(|_| {println!("termination signal received"); Ok(())}) | ||
); | ||
|
||
while !stop_signal.load(Ordering::SeqCst) { | ||
thread::sleep(Duration::from_secs(1)); | ||
} | ||
run_prover(stop_signal, env::var("POD_NAME").unwrap_or("default".to_string()).clone()); | ||
|
||
println!("terminate signal received"); | ||
rt.shutdown_now(); | ||
println!("prover terminated"); | ||
} |
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 |
---|---|---|
|
@@ -22,3 +22,4 @@ rust-crypto = "0.2" | |
rustc-hex = "2.0.1" | ||
|
||
signal-hook = "0.1.8" | ||
tokio = "0.1.18" |
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