@@ -66,58 +66,64 @@ mosaic
66
66
. option ( '-s,--password <file>' , 'the path to the password file on your machine; you must use this together with --unlock' )
67
67
. option ( '-g,--withoutGraphNode' , 'boolean flag which decides if graph node should be started' )
68
68
. action ( ( chain : string , options ) => {
69
- let chainInput = chain ;
70
- let optionInput = Object . assign ( { } , options ) ;
71
- if ( ! validateCLIOptions ( chain , optionInput ) ) {
72
- process . exit ( 1 ) ;
73
- }
74
- if ( DevChainOptions . isDevChain ( chain , options ) ) {
75
- const devParams = DevChainOptions . getDevChainParams ( chain , options ) ;
76
- chainInput = devParams . chain ;
77
- optionInput = devParams . options ;
78
- }
79
- const {
80
- mosaicDir,
81
- port,
82
- rpcPort,
83
- websocketPort,
84
- keepAfterStop,
85
- unlock,
86
- password,
87
- originChain,
88
- } = NodeOptions . parseOptions ( optionInput , chainInput ) ;
89
- const nodeDescription : NodeDescription = {
90
- chain : chainInput ,
91
- mosaicDir,
92
- port,
93
- rpcPort,
94
- websocketPort,
95
- keepAfterStop,
96
- unlock,
97
- password,
98
- originChain,
99
- client : optionInput . client ,
100
- } ;
101
- const node : Node = NodeFactory . create ( nodeDescription ) ;
102
- node . start ( ) ;
69
+ try {
70
+ let chainInput = chain ;
71
+ let optionInput = Object . assign ( { } , options ) ;
72
+ if ( ! validateCLIOptions ( chain , optionInput ) ) {
73
+ process . exit ( 1 ) ;
74
+ }
75
+ if ( DevChainOptions . isDevChain ( chain , options ) ) {
76
+ const devParams = DevChainOptions . getDevChainParams ( chain , options ) ;
77
+ chainInput = devParams . chain ;
78
+ optionInput = devParams . options ;
79
+ // Dev chain should always start with geth.
80
+ optionInput . client = GETH_CLIENT ;
81
+ }
82
+ const {
83
+ mosaicDir,
84
+ port,
85
+ rpcPort,
86
+ websocketPort,
87
+ keepAfterStop,
88
+ unlock,
89
+ password,
90
+ originChain,
91
+ } = NodeOptions . parseOptions ( optionInput , chainInput ) ;
92
+ const nodeDescription : NodeDescription = {
93
+ chain : chainInput ,
94
+ mosaicDir,
95
+ port,
96
+ rpcPort,
97
+ websocketPort,
98
+ keepAfterStop,
99
+ unlock,
100
+ password,
101
+ originChain,
102
+ client : optionInput . client ,
103
+ } ;
104
+ const node : Node = NodeFactory . create ( nodeDescription ) ;
105
+ node . start ( ) ;
103
106
104
- if ( ! optionInput . withoutGraphNode ) {
105
- const graphDescription : GraphDescription = GraphOptions . parseOptions ( optionInput , chainInput ) ;
106
- // reuse params from node start command
107
- graphDescription . mosaicDir = mosaicDir ;
108
- graphDescription . ethereumRpcPort = rpcPort ;
109
- graphDescription . ethereumClient = nodeDescription . client ;
107
+ if ( ! optionInput . withoutGraphNode ) {
108
+ const graphDescription : GraphDescription = GraphOptions . parseOptions ( optionInput , chainInput ) ;
109
+ // reuse params from node start command
110
+ graphDescription . mosaicDir = mosaicDir ;
111
+ graphDescription . ethereumRpcPort = rpcPort ;
112
+ graphDescription . ethereumClient = nodeDescription . client ;
110
113
111
- new Graph ( graphDescription ) . start ( ) . then ( ( ) => {
112
- let subGraphDeployer ;
113
- // options.origin passed only in case of starting an auxiliary chain
114
- if ( optionInput . origin ) {
115
- subGraphDeployer = new SubGraphDeployer ( graphDescription , optionInput . origin , chainInput ) ;
116
- } else {
117
- subGraphDeployer = new SubGraphDeployer ( graphDescription , chainInput , null ) ;
118
- }
119
- return subGraphDeployer . deploy ( ) ;
120
- } ) ;
114
+ new Graph ( graphDescription ) . start ( ) . then ( ( ) => {
115
+ let subGraphDeployer ;
116
+ // options.origin passed only in case of starting an auxiliary chain
117
+ if ( optionInput . origin ) {
118
+ subGraphDeployer = new SubGraphDeployer ( graphDescription , optionInput . origin , chainInput ) ;
119
+ } else {
120
+ subGraphDeployer = new SubGraphDeployer ( graphDescription , chainInput , null ) ;
121
+ }
122
+ return subGraphDeployer . deploy ( ) ;
123
+ } ) ;
124
+ }
125
+ } catch ( e ) {
126
+ Logger . error ( `Error starting node: ${ e } ` ) ;
121
127
}
122
128
} )
123
129
. parse ( process . argv ) ;
0 commit comments