Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd70af29

Browse files
author
Stepan Neretin
committed
rethink idea of change data dir to just start node with custom data dir
1 parente63371a commitd70af29

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

‎testgres/node.py‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -440,15 +440,7 @@ def logs_dir(self):
440440

441441
@property
442442
defdata_dir(self):
443-
# NOTE: we can't run initdb without user's args
444-
ifhasattr(self,'_data_dir'):
445-
returnself._data_dir
446-
else:
447-
returnos.path.join(self.base_dir,DATA_DIR)
448-
449-
@data_dir.setter
450-
defdata_dir(self,value):
451-
self._data_dir=value
443+
returnos.path.join(self.base_dir,DATA_DIR)
452444

453445
@property
454446
defutils_log_file(self):
@@ -894,7 +886,7 @@ def get_control_data(self):
894886

895887
returnout_dict
896888

897-
defslow_start(self,replica=False,dbname='template1',username=None,max_attempts=0):
889+
defslow_start(self,replica=False,dbname='template1',username=None,max_attempts=0,custom_data_dir=None):
898890
"""
899891
Starts the PostgreSQL instance and then polls the instance
900892
until it reaches the expected state (primary or replica). The state is checked
@@ -907,7 +899,7 @@ def slow_start(self, replica=False, dbname='template1', username=None, max_attem
907899
If False, waits for the instance to be in primary mode. Default is False.
908900
max_attempts:
909901
"""
910-
self.start()
902+
self.start(custom_data_dir=custom_data_dir)
911903

912904
ifreplica:
913905
query='SELECT pg_is_in_recovery()'
@@ -939,7 +931,7 @@ def _detect_port_conflict(self, log_files0, log_files1):
939931
returnTrue
940932
returnFalse
941933

942-
defstart(self,params=[],wait=True):
934+
defstart(self,params=[],wait=True,custom_data_dir=None):
943935
"""
944936
Starts the PostgreSQL node using pg_ctl if node has not been started.
945937
By default, it waits for the operation to complete before returning.
@@ -960,7 +952,7 @@ def start(self, params=[], wait=True):
960952
returnself
961953

962954
_params= [self._get_bin_path("pg_ctl"),
963-
"-D",self.data_dir,
955+
"-D",custom_data_dirifcustom_data_direlseself.data_dir,
964956
"-l",self.pg_log_file,
965957
"-w"ifwaitelse'-W',# --wait or --no-wait
966958
"start"]+params# yapf: disable
@@ -1035,7 +1027,7 @@ def LOCAL__raise_cannot_start_node__std(from_exception):
10351027
self.is_started=True
10361028
returnself
10371029

1038-
defstop(self,params=[],wait=True):
1030+
defstop(self,params=[],wait=True,custom_data_dir=None):
10391031
"""
10401032
Stops the PostgreSQL node using pg_ctl if the node has been started.
10411033
@@ -1051,7 +1043,7 @@ def stop(self, params=[], wait=True):
10511043

10521044
_params= [
10531045
self._get_bin_path("pg_ctl"),
1054-
"-D",self.data_dir,
1046+
"-D",custom_data_dirifcustom_data_direlseself.data_dir,
10551047
"-w"ifwaitelse'-W',# --wait or --no-wait
10561048
"stop"
10571049
]+params# yapf: disable

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp