Skip to content

Commit f24349f

Browse files
committed
- make.bat added to build package
- patroni_start.bat will run patroni with etcd on client machine - postgres-win.yml used as a settings template
1 parent b926e62 commit f24349f

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed

make.bat

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@ECHO off
2+
SET MD=output
3+
SET ETCD_REF=https://github.com/etcd-io/etcd/releases/download/v3.3.13/etcd-v3.3.13-windows-amd64.zip
4+
SET PATRONI_REF=https://github.com/zalando/patroni/archive/v1.5.6.zip
5+
6+
7+
ECHO --- Start bootstrapping ---
8+
9+
RMDIR /Q /S %MD% patroni
10+
MKDIR %MD%
11+
copy src\*.* %MD%\
12+
13+
@ECHO on
14+
15+
16+
rem @ECHO --- Download ETCD ---
17+
rem powershell -Command "[Net.ServicePointManager]::SecurityProtocol = 'tls12, tls11, tls'; ((new-object net.webclient).DownloadFile('%ETCD_REF%', '%TEMP%\etcd.zip'))"
18+
rem powershell -Command "$shell = New-Object -ComObject Shell.Application; $zip_src = $shell.NameSpace('%TEMP%\etcd.zip'); $zip_dest = $shell.NameSpace((Resolve-Path '%CD%').Path); $zip_dest.CopyHere($zip_src.Items(), 1044)"
19+
rem MOVE etcd-* output\etcd
20+
21+
@ECHO --- Download PATRONI ---
22+
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = 'tls12, tls11, tls'; ((new-object net.webclient).DownloadFile('%PATRONI_REF%', '%TEMP%\patroni.zip'))"
23+
powershell -Command "$shell = New-Object -ComObject Shell.Application; $zip_src = $shell.NameSpace('%TEMP%\patroni.zip'); $zip_dest = $shell.NameSpace((Resolve-Path '%CD%').Path); $zip_dest.CopyHere($zip_src.Items(), 1044)"
24+
MOVE patroni-* patroni
25+
26+
rem CD patroni
27+
rem virtualenv.exe venv || EXIT /B 1
28+
rem CALL venv\Scripts\activate || EXIT /B 1
29+
rem pip install -r requirements.txt || EXIT /B 1
30+
rem pip install psycopg2-binary || EXIT /B 1
31+
rem CALL venv\Scripts\deactivate || EXIT /B 1

src/patroni_start.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SETLOCAL
2+
3+
SET PYTHONPATH=venv\Scripts
4+
5+
START etcd\etcd.exe --data-dir=data\etcd
6+
7+
%PYTHONPATH%\python.exe patroni\patroni.py postgres-win.yml

src/postgres-win.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
scope: batman
2+
#namespace: /service/
3+
name: postgresql0
4+
5+
restapi:
6+
listen: 127.0.0.1:8008
7+
connect_address: 127.0.0.1:8008
8+
# certfile: /etc/ssl/certs/ssl-cert-snakeoil.pem
9+
# keyfile: /etc/ssl/private/ssl-cert-snakeoil.key
10+
# authentication:
11+
# username: username
12+
# password: password
13+
14+
# ctl:
15+
# insecure: false # Allow connections to SSL sites without certs
16+
# certfile: /etc/ssl/certs/ssl-cert-snakeoil.pem
17+
# cacert: /etc/ssl/certs/ssl-cacert-snakeoil.pem
18+
19+
etcd:
20+
host: 127.0.0.1:2379
21+
22+
bootstrap:
23+
# this section will be written into Etcd:/<namespace>/<scope>/config after initializing new cluster
24+
# and all other cluster members will use it as a `global configuration`
25+
dcs:
26+
ttl: 30
27+
loop_wait: 10
28+
retry_timeout: 10
29+
maximum_lag_on_failover: 1048576
30+
# master_start_timeout: 300
31+
# synchronous_mode: false
32+
#standby_cluster:
33+
#host: 127.0.0.1
34+
#port: 1111
35+
#primary_slot_name: patroni
36+
postgresql:
37+
use_pg_rewind: true
38+
# use_slots: true
39+
parameters:
40+
# wal_level: hot_standby
41+
# hot_standby: "on"
42+
# wal_keep_segments: 8
43+
# max_wal_senders: 10
44+
# max_replication_slots: 10
45+
# wal_log_hints: "on"
46+
# archive_mode: "on"
47+
# archive_timeout: 1800s
48+
# archive_command: mkdir -p ../wal_archive && test ! -f ../wal_archive/%f && cp %p ../wal_archive/%f
49+
# recovery_conf:
50+
# restore_command: cp ../wal_archive/%f %p
51+
52+
# some desired options for 'initdb'
53+
initdb: # Note: It needs to be a list (some options need values, others are switches)
54+
- encoding: UTF8
55+
- data-checksums
56+
57+
pg_hba: # Add following lines to pg_hba.conf after running 'initdb'
58+
- host replication replicator 127.0.0.1/32 md5
59+
- host all all 0.0.0.0/0 md5
60+
# - hostssl all all 0.0.0.0/0 md5
61+
62+
# Additional script to be launched after initial cluster creation (will be passed the connection URL as parameter)
63+
# post_init: /usr/local/bin/setup_cluster.sh
64+
65+
# Some additional users users which needs to be created after initializing new cluster
66+
users:
67+
admin:
68+
password: admin
69+
options:
70+
- createrole
71+
- createdb
72+
73+
postgresql:
74+
listen: 127.0.0.1:5432
75+
connect_address: 127.0.0.1:5432
76+
data_dir: data/postgresql0
77+
# bin_dir: C:/bigsql/pg11/bin
78+
# config_dir:
79+
pgpass: tmp/pgpass0
80+
authentication:
81+
replication:
82+
username: replicator
83+
password: rep-pass
84+
superuser:
85+
username: postgres
86+
password: zalando
87+
parameters:
88+
unix_socket_directories: '.'
89+
90+
#watchdog:
91+
# mode: automatic # Allowed values: off, automatic, required
92+
# device: /dev/watchdog
93+
# safety_margin: 5
94+
95+
tags:
96+
nofailover: false
97+
noloadbalance: false
98+
clonefrom: false
99+
nosync: false

0 commit comments

Comments
 (0)