From cef9cafa2a573d5682662735a4f5a00c630db11a Mon Sep 17 00:00:00 2001 From: Pavlo Golub Date: Fri, 14 Aug 2020 14:52:23 +0200 Subject: [PATCH] [+] Add service wrappers to the package, closes #2 --- make.bat | 8 +++ src/etcd_service.xml | 7 ++ src/{postgres-win0.yml => patroni.yml} | 0 src/patroni_service.xml | 14 ++++ src/postgres-win1.yml | 99 -------------------------- src/vip_service.xml | 7 ++ 6 files changed, 36 insertions(+), 99 deletions(-) create mode 100644 src/etcd_service.xml rename src/{postgres-win0.yml => patroni.yml} (100%) create mode 100644 src/patroni_service.xml delete mode 100644 src/postgres-win1.yml create mode 100644 src/vip_service.xml diff --git a/make.bat b/make.bat index d7c2bcc..d2511ac 100644 --- a/make.bat +++ b/make.bat @@ -3,6 +3,7 @@ SET MD=patroni-win-x64 SET ETCD_REF=https://github.com/etcd-io/etcd/releases/download/v3.3.22/etcd-v3.3.22-windows-amd64.zip SET PATRONI_REF=https://github.com/zalando/patroni/archive/v1.6.5.zip SET MICRO_REF=https://github.com/zyedidia/micro/releases/download/v2.0.6/micro-2.0.6-win64.zip +SET WINSW_REF=https://github.com/winsw/winsw/releases/download/v2.9.0/WinSW.NET461.exe @ECHO --- Start bootstrapping --- @@ -28,6 +29,13 @@ powershell -Command "Expand-Archive '%TEMP%\micro.zip' '%CD%'" MOVE micro-* %MD%\micro @ECHO --- MICRO downloaded --- +@ECHO --- Download WINSW --- +MKDIR %MD%\service +curl %MICRO_REF% --location --output %MD%\service\patroni_service.exe +COPY %MD%\service\patroni_service.exe %MD%\service\etcd_service.exe /B +COPY %MD%\service\patroni_service.exe %MD%\service\vip_service.exe /B +@ECHO --- WINSW downloaded --- + @ECHO --- Download PATRONI --- curl %PATRONI_REF% --location --output %TEMP%\patroni.zip powershell -Command "Expand-Archive '%TEMP%\patroni.zip' '%CD%'" diff --git a/src/etcd_service.xml b/src/etcd_service.xml new file mode 100644 index 0000000..12845fe --- /dev/null +++ b/src/etcd_service.xml @@ -0,0 +1,7 @@ + + etcd + etcd + Distributed reliable key-value store + %BASE%\etcd\ectd.exe + --config-file=%BASE%\etcd.conf + \ No newline at end of file diff --git a/src/postgres-win0.yml b/src/patroni.yml similarity index 100% rename from src/postgres-win0.yml rename to src/patroni.yml diff --git a/src/patroni_service.xml b/src/patroni_service.xml new file mode 100644 index 0000000..155e288 --- /dev/null +++ b/src/patroni_service.xml @@ -0,0 +1,14 @@ + + patroni + Patroni HA Windows Service + Patroni high-availability solution using Python and etcd + C:\Users\pasha\AppData\Local\Programs\Python\Python38\python.exe + %BASE%\patroni\patroni.py %BASE%\postgres-win0.yml + true + + %BASE%\log + + postgres + 12345 + + \ No newline at end of file diff --git a/src/postgres-win1.yml b/src/postgres-win1.yml deleted file mode 100644 index f26de35..0000000 --- a/src/postgres-win1.yml +++ /dev/null @@ -1,99 +0,0 @@ -scope: batman -#namespace: /service/ -name: postgresql1 - -restapi: - listen: 127.0.0.1:8009 - connect_address: 127.0.0.1:8009 -# certfile: /etc/ssl/certs/ssl-cert-snakeoil.pem -# keyfile: /etc/ssl/private/ssl-cert-snakeoil.key -# authentication: -# username: username -# password: password - -# ctl: -# insecure: false # Allow connections to SSL sites without certs -# certfile: /etc/ssl/certs/ssl-cert-snakeoil.pem -# cacert: /etc/ssl/certs/ssl-cacert-snakeoil.pem - -etcd: - host: 127.0.0.1:2379 - -bootstrap: - # this section will be written into Etcd:///config after initializing new cluster - # and all other cluster members will use it as a `global configuration` - dcs: - ttl: 30 - loop_wait: 10 - retry_timeout: 10 - maximum_lag_on_failover: 1048576 -# master_start_timeout: 300 -# synchronous_mode: false - #standby_cluster: - #host: 127.0.0.1 - #port: 1111 - #primary_slot_name: patroni - postgresql: - use_pg_rewind: true -# use_slots: true - parameters: -# wal_level: hot_standby -# hot_standby: "on" -# wal_keep_segments: 8 -# max_wal_senders: 10 -# max_replication_slots: 10 -# wal_log_hints: "on" -# archive_mode: "on" -# archive_timeout: 1800s -# archive_command: mkdir -p ../wal_archive && test ! -f ../wal_archive/%f && cp %p ../wal_archive/%f -# recovery_conf: -# restore_command: cp ../wal_archive/%f %p - - # some desired options for 'initdb' - initdb: # Note: It needs to be a list (some options need values, others are switches) - - encoding: UTF8 - - data-checksums - - pg_hba: # Add following lines to pg_hba.conf after running 'initdb' - - host replication replicator 127.0.0.1/32 md5 - - host all all 0.0.0.0/0 md5 -# - hostssl all all 0.0.0.0/0 md5 - - # Additional script to be launched after initial cluster creation (will be passed the connection URL as parameter) -# post_init: /usr/local/bin/setup_cluster.sh - - # Some additional users users which needs to be created after initializing new cluster - users: - admin: - password: admin - options: - - createrole - - createdb - -postgresql: - listen: 127.0.0.1:5433 - connect_address: 127.0.0.1:5433 - data_dir: data/postgresql1 -# bin_dir: C:/bigsql/pg11/bin -# config_dir: - pgpass: data/pgpass1 - authentication: - replication: - username: replicator - password: rep-pass - superuser: - username: postgres - password: zalando - parameters: - unix_socket_directories: '.' - -#watchdog: -# mode: automatic # Allowed values: off, automatic, required -# device: /dev/watchdog -# safety_margin: 5 - -tags: - nofailover: false - noloadbalance: false - clonefrom: false - nosync: false diff --git a/src/vip_service.xml b/src/vip_service.xml new file mode 100644 index 0000000..470f405 --- /dev/null +++ b/src/vip_service.xml @@ -0,0 +1,7 @@ + + vip-manager + vip-manager + Manager for a virtual IP based on state kept in etcd or Consul + %BASE%\vip-manager\vip-manager.exe + -config %BASE%\vip-manager.yml + \ No newline at end of file