File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -172,23 +172,23 @@ pub async fn parse(path: &str) -> Result<(), Error> {
172
172
let mut file = match File :: open ( path) . await {
173
173
Ok ( file) => file,
174
174
Err ( err) => {
175
- error ! ( "{:? }" , err) ;
175
+ error ! ( "Could not open '{}': { }" , path , err. to_string ( ) ) ;
176
176
return Err ( Error :: BadConfig ) ;
177
177
}
178
178
} ;
179
179
180
180
match file. read_to_string ( & mut contents) . await {
181
181
Ok ( _) => ( ) ,
182
182
Err ( err) => {
183
- error ! ( "{:? }" , err) ;
183
+ error ! ( "Could not read config file: { }" , err. to_string ( ) ) ;
184
184
return Err ( Error :: BadConfig ) ;
185
185
}
186
186
} ;
187
187
188
188
let config: Config = match toml:: from_str ( & contents) {
189
189
Ok ( config) => config,
190
190
Err ( err) => {
191
- error ! ( "{:? }" , err) ;
191
+ error ! ( "Could not parse config file: { }" , err. to_string ( ) ) ;
192
192
return Err ( Error :: BadConfig ) ;
193
193
}
194
194
} ;
@@ -200,6 +200,17 @@ pub async fn parse(path: &str) -> Result<(), Error> {
200
200
let mut dup_check = HashSet :: new ( ) ;
201
201
let mut primary_count = 0 ;
202
202
203
+ match shard. 0 . parse :: < usize > ( ) {
204
+ Ok ( _) => ( ) ,
205
+ Err ( _) => {
206
+ error ! (
207
+ "Shard '{}' is not a valid number, shards must be numbered starting at 0" ,
208
+ shard. 0
209
+ ) ;
210
+ return Err ( Error :: BadConfig ) ;
211
+ }
212
+ } ;
213
+
203
214
if shard. 1 . servers . len ( ) == 0 {
204
215
error ! ( "Shard {} has no servers configured" , shard. 0 ) ;
205
216
return Err ( Error :: BadConfig ) ;
Original file line number Diff line number Diff line change @@ -75,8 +75,16 @@ async fn main() {
75
75
return ;
76
76
}
77
77
78
+ let args = std:: env:: args ( ) . collect :: < Vec < String > > ( ) ;
79
+
80
+ let config_file = if args. len ( ) == 2 {
81
+ args[ 1 ] . to_string ( )
82
+ } else {
83
+ String :: from ( "pgcat.toml" )
84
+ } ;
85
+
78
86
// Prepare the config
79
- match config:: parse ( "pgcat.toml" ) . await {
87
+ match config:: parse ( & config_file ) . await {
80
88
Ok ( _) => ( ) ,
81
89
Err ( err) => {
82
90
error ! ( "Config parse error: {:?}" , err) ;
You can’t perform that action at this time.
0 commit comments