@@ -58,6 +58,8 @@ struct Args {
5858 pg_bin_dir : Utf8PathBuf ,
5959 #[ clap( long) ]
6060 pg_lib_dir : Utf8PathBuf ,
61+ #[ clap( long) ]
62+ pg_port : Option < u16 > , // port to run postgres on, 5432 is default
6163}
6264
6365#[ serde_with:: serde_as]
@@ -74,6 +76,13 @@ enum EncryptionSecret {
7476 KMS { key_id : String } ,
7577}
7678
79+ // copied from pageserver_api::config::defaults::DEFAULT_LOCALE to avoid dependency just for a constant
80+ const DEFAULT_LOCALE : & str = if cfg ! ( target_os = "macos" ) {
81+ "C"
82+ } else {
83+ "C.UTF-8"
84+ } ;
85+
7786#[ tokio:: main]
7887pub ( crate ) async fn main ( ) -> anyhow:: Result < ( ) > {
7988 utils:: logging:: init (
@@ -97,6 +106,10 @@ pub(crate) async fn main() -> anyhow::Result<()> {
97106 let working_directory = args. working_directory ;
98107 let pg_bin_dir = args. pg_bin_dir ;
99108 let pg_lib_dir = args. pg_lib_dir ;
109+ let pg_port = args. pg_port . unwrap_or_else ( || {
110+ info ! ( "pg_port not specified, using default 5432" ) ;
111+ 5432
112+ } ) ;
100113
101114 // Initialize AWS clients only if s3_prefix is specified
102115 let ( aws_config, kms_client) = if args. s3_prefix . is_some ( ) {
@@ -180,7 +193,7 @@ pub(crate) async fn main() -> anyhow::Result<()> {
180193 let superuser = "cloud_admin" ; // XXX: this shouldn't be hard-coded
181194 postgres_initdb:: do_run_initdb ( postgres_initdb:: RunInitdbArgs {
182195 superuser,
183- locale : "en_US.UTF-8" , // XXX: this shouldn't be hard-coded,
196+ locale : DEFAULT_LOCALE , // XXX: this shouldn't be hard-coded,
184197 pg_version,
185198 initdb_bin : pg_bin_dir. join ( "initdb" ) . as_ref ( ) ,
186199 library_search_path : & pg_lib_dir, // TODO: is this right? Prob works in compute image, not sure about neon_local.
@@ -197,6 +210,7 @@ pub(crate) async fn main() -> anyhow::Result<()> {
197210 let mut postgres_proc = tokio:: process:: Command :: new ( pgbin)
198211 . arg ( "-D" )
199212 . arg ( & pgdata_dir)
213+ . args ( [ "-p" , & format ! ( "{pg_port}" ) ] )
200214 . args ( [ "-c" , "wal_level=minimal" ] )
201215 . args ( [ "-c" , "shared_buffers=10GB" ] )
202216 . args ( [ "-c" , "max_wal_senders=0" ] )
@@ -216,6 +230,7 @@ pub(crate) async fn main() -> anyhow::Result<()> {
216230 ) ,
217231 ] )
218232 . env_clear ( )
233+ . env ( "LD_LIBRARY_PATH" , & pg_lib_dir)
219234 . stdout ( std:: process:: Stdio :: piped ( ) )
220235 . stderr ( std:: process:: Stdio :: piped ( ) )
221236 . spawn ( )
@@ -232,7 +247,7 @@ pub(crate) async fn main() -> anyhow::Result<()> {
232247
233248 // Create neondb database in the running postgres
234249 let restore_pg_connstring =
235- format ! ( "host=localhost port=5432 user={superuser} dbname=postgres" ) ;
250+ format ! ( "host=localhost port={pg_port} user={superuser} dbname=postgres" ) ;
236251
237252 let start_time = std:: time:: Instant :: now ( ) ;
238253
@@ -314,6 +329,7 @@ pub(crate) async fn main() -> anyhow::Result<()> {
314329 . arg ( & source_connection_string)
315330 // how we run it
316331 . env_clear ( )
332+ . env ( "LD_LIBRARY_PATH" , & pg_lib_dir)
317333 . kill_on_drop ( true )
318334 . stdout ( std:: process:: Stdio :: piped ( ) )
319335 . stderr ( std:: process:: Stdio :: piped ( ) )
@@ -347,6 +363,7 @@ pub(crate) async fn main() -> anyhow::Result<()> {
347363 . arg ( & dumpdir)
348364 // how we run it
349365 . env_clear ( )
366+ . env ( "LD_LIBRARY_PATH" , & pg_lib_dir)
350367 . kill_on_drop ( true )
351368 . stdout ( std:: process:: Stdio :: piped ( ) )
352369 . stderr ( std:: process:: Stdio :: piped ( ) )
0 commit comments