Coverage Summary for Class: FullNodeRunner (co.rsk)
Class |
Class, %
|
Method, %
|
Line, %
|
FullNodeRunner |
0%
(0/1)
|
0%
(0/4)
|
0%
(0/24)
|
1 /*
2 * This file is part of RskJ
3 * Copyright (C) 2017 RSK Labs Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 package co.rsk;
19
20 import co.rsk.config.InternalService;
21 import co.rsk.config.RskSystemProperties;
22 import co.rsk.util.SystemUtils;
23 import org.ethereum.net.eth.EthVersion;
24 import org.ethereum.util.BuildInfo;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28 import java.util.Collections;
29 import java.util.List;
30 import java.util.stream.Collectors;
31
32 public class FullNodeRunner implements NodeRunner {
33 private static Logger logger = LoggerFactory.getLogger("fullnoderunner");
34
35 private final List<InternalService> internalServices;
36 private final RskSystemProperties rskSystemProperties;
37 private final BuildInfo buildInfo;
38
39 public FullNodeRunner(
40 List<InternalService> internalServices,
41 RskSystemProperties rskSystemProperties,
42 BuildInfo buildInfo) {
43 this.internalServices = Collections.unmodifiableList(internalServices);
44 this.rskSystemProperties = rskSystemProperties;
45 this.buildInfo = buildInfo;
46 }
47
48 @Override
49 public void run() {
50 logger.info("Starting RSK");
51
52 logger.info(
53 "Running {}, core version: {}-{}",
54 rskSystemProperties.genesisInfo(),
55 rskSystemProperties.projectVersion(),
56 rskSystemProperties.projectVersionModifier()
57 );
58 buildInfo.printInfo(logger);
59
60 if (rskSystemProperties.shouldPrintSystemInfo()) {
61 SystemUtils.printSystemInfo(logger);
62 }
63
64 for (InternalService internalService : internalServices) {
65 internalService.start();
66 }
67
68 if (logger.isInfoEnabled()) {
69 String versions = EthVersion.supported().stream().map(EthVersion::name).collect(Collectors.joining(", "));
70 logger.info("Capability eth version: [{}]", versions);
71 }
72
73 logger.info("done");
74 }
75
76 @Override
77 public void stop() {
78 logger.info("Shutting down RSK node");
79
80 for (int i = internalServices.size() - 1; i >= 0; i--) {
81 internalServices.get(i).stop();
82 }
83
84 logger.info("RSK node Shut down");
85 }
86 }