|
14 | 14 | // You should have received a copy of the GNU Affero General Public License |
15 | 15 | // along with this program. If not, see <https://www.gnu.org/licenses/>. |
16 | 16 |
|
| 17 | +use std::env; |
17 | 18 | use std::fs; |
18 | 19 | use std::path::Path; |
19 | 20 | use std::sync::Arc; |
20 | | -use std::time::{SystemTime, UNIX_EPOCH}; |
| 21 | +use std::time::{Duration, SystemTime, UNIX_EPOCH}; |
21 | 22 |
|
22 | 23 | use ccore::{ |
23 | 24 | AccountProvider, Client, ClientService, EngineType, Miner, MinerService, Scheme, ShardValidator, Stratum, |
24 | 25 | StratumConfig, StratumError, |
25 | 26 | }; |
26 | 27 | use cdiscovery::{KademliaConfig, KademliaExtension, UnstructuredConfig, UnstructuredExtension}; |
| 28 | +use cfinally::finally; |
27 | 29 | use ckeystore::accounts_dir::RootDiskDirectory; |
28 | 30 | use ckeystore::KeyStore; |
29 | 31 | use clap::ArgMatches; |
@@ -170,6 +172,17 @@ pub fn run_node(matches: ArgMatches) -> Result<(), String> { |
170 | 172 | let _event_loop = EventLoop::spawn(); |
171 | 173 | let config = load_config(&matches)?; |
172 | 174 |
|
| 175 | + // FIXME: It is the hotfix for #348. |
| 176 | + // Remove the below code if you find the proper way to solve #348. |
| 177 | + let _wait = finally(|| { |
| 178 | + const DEFAULT: u64 = 1; |
| 179 | + let wait_before_shutdown = env::var_os("WAIT_BEFORE_SHUTDOWN") |
| 180 | + .and_then(|sec| sec.into_string().ok()) |
| 181 | + .and_then(|sec| sec.parse().ok()) |
| 182 | + .unwrap_or(DEFAULT); |
| 183 | + ::std::thread::sleep(Duration::from_secs(wait_before_shutdown)); |
| 184 | + }); |
| 185 | + |
173 | 186 | let scheme = config.operating.chain.scheme()?; |
174 | 187 |
|
175 | 188 | let instance_id = config.operating.instance_id.unwrap_or( |
|
0 commit comments