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> {
172172 let mut file = match File :: open ( path) . await {
173173 Ok ( file) => file,
174174 Err ( err) => {
175- error ! ( "{:? }" , err) ;
175+ error ! ( "Could not open '{}': { }" , path , err. to_string ( ) ) ;
176176 return Err ( Error :: BadConfig ) ;
177177 }
178178 } ;
179179
180180 match file. read_to_string ( & mut contents) . await {
181181 Ok ( _) => ( ) ,
182182 Err ( err) => {
183- error ! ( "{:? }" , err) ;
183+ error ! ( "Could not read config file: { }" , err. to_string ( ) ) ;
184184 return Err ( Error :: BadConfig ) ;
185185 }
186186 } ;
187187
188188 let config: Config = match toml:: from_str ( & contents) {
189189 Ok ( config) => config,
190190 Err ( err) => {
191- error ! ( "{:? }" , err) ;
191+ error ! ( "Could not parse config file: { }" , err. to_string ( ) ) ;
192192 return Err ( Error :: BadConfig ) ;
193193 }
194194 } ;
@@ -200,6 +200,17 @@ pub async fn parse(path: &str) -> Result<(), Error> {
200200 let mut dup_check = HashSet :: new ( ) ;
201201 let mut primary_count = 0 ;
202202
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+
203214 if shard. 1 . servers . len ( ) == 0 {
204215 error ! ( "Shard {} has no servers configured" , shard. 0 ) ;
205216 return Err ( Error :: BadConfig ) ;
Original file line number Diff line number Diff line change @@ -75,8 +75,16 @@ async fn main() {
7575 return ;
7676 }
7777
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+
7886 // Prepare the config
79- match config:: parse ( "pgcat.toml" ) . await {
87+ match config:: parse ( & config_file ) . await {
8088 Ok ( _) => ( ) ,
8189 Err ( err) => {
8290 error ! ( "Config parse error: {:?}" , err) ;
You can’t perform that action at this time.
0 commit comments