├── .vscode └── temp.sql ├── common ├── postgresql │ ├── .pgpass │ └── etc │ │ ├── pg_ident.conf │ │ ├── pg_hba.conf │ │ └── postgresql.conf ├── horizon │ ├── bin │ │ ├── horizon │ │ └── start │ └── etc │ │ └── horizon.env ├── core │ └── bin │ │ └── start └── supervisor │ └── etc │ └── supervisord.conf ├── Makefile ├── dependencies ├── install ├── .travis.yml ├── standalone └── core │ └── etc │ └── stellar-core.cfg ├── travis.go ├── Dockerfile ├── Dockerfile.testing ├── testnet └── core │ └── etc │ └── stellar-core.cfg ├── pubnet └── core │ └── etc │ └── stellar-core.cfg ├── start └── README.md /.vscode/temp.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /common/postgresql/.pgpass: -------------------------------------------------------------------------------- 1 | *:*:*:stellar:__PGPASS__ 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | __PHONY__: build build-testing 2 | 3 | build: 4 | docker build -t stellar/quickstart -f Dockerfile . 5 | 6 | build-testing: 7 | docker build -t stellar/quickstart:testing -f Dockerfile.testing . -------------------------------------------------------------------------------- /common/horizon/bin/horizon: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # This file is a simple wrapper around horizon that establishes the proper 4 | # environment variables before executing the actual binary. 5 | 6 | source /opt/stellar/horizon/etc/horizon.env 7 | exec /usr/local/bin/horizon $@ 8 | -------------------------------------------------------------------------------- /common/core/bin/start: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while ! psql -U stellar -c 'select 1' core &> /dev/null ; do 4 | echo "Waiting for postgres to be available..." 5 | sleep 1 6 | done 7 | 8 | echo "starting core..." 9 | set -e 10 | exec /usr/local/bin/stellar-core --conf "/opt/stellar/core/etc/stellar-core.cfg" run 11 | -------------------------------------------------------------------------------- /dependencies: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | set -e 3 | 4 | # dependencies 5 | apt-get update 6 | apt-get install -y curl git libpq-dev libsqlite3-dev libsasl2-dev postgresql-client postgresql postgresql-contrib sudo vim zlib1g-dev supervisor \ 7 | jq netcat # Parsing stellar-core JSON for standalone network and checking core HTTP server 8 | apt-get clean 9 | 10 | echo "\nDone installing dependencies...\n" 11 | -------------------------------------------------------------------------------- /common/horizon/bin/start: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | while ! psql -U stellar -c 'select 1' horizon &> /dev/null ; do 6 | echo "Waiting for postgres to be available..." 7 | sleep 1 8 | done 9 | 10 | while ! stellar-core --conf /opt/stellar/core/etc/stellar-core.cfg http-command info &> /dev/null ; do 11 | echo "Waiting for stellar-core to be available..." 12 | sleep 1 13 | done 14 | 15 | echo "starting horizon..." 16 | set -e 17 | exec $DIR/horizon 18 | -------------------------------------------------------------------------------- /common/horizon/etc/horizon.env: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export DATABASE_URL="postgres://stellar:__PGPASS__@localhost/horizon" 4 | export STELLAR_CORE_DATABASE_URL="postgres://stellar:__PGPASS__@localhost/core" 5 | export STELLAR_CORE_URL="http://localhost:11626" 6 | export LOG_LEVEL="info" 7 | export INGEST="true" 8 | # It's fine for CATCHUP_RECENT stellar-core. 9 | export INGEST_FAILED_TRANSACTIONS="true" 10 | export PER_HOUR_RATE_LIMIT="72000" 11 | export NETWORK_PASSPHRASE="__NETWORK__" 12 | export DISABLE_ASSET_STATS="true" 13 | export HISTORY_ARCHIVE_URLS="__ARCHIVE__" 14 | -------------------------------------------------------------------------------- /install: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | set -e 3 | 4 | # stellar-core 5 | wget -O stellar-core.deb https://s3.amazonaws.com/stellar.org/releases/stellar-core/stellar-core-${STELLAR_CORE_VERSION}_amd64.deb 6 | dpkg -i stellar-core.deb 7 | rm stellar-core.deb 8 | 9 | # horizon 10 | wget -O horizon.tar.gz https://github.com/stellar/go/releases/download/horizon-v${HORIZON_VERSION}/horizon-v${HORIZON_VERSION}-linux-amd64.tar.gz 11 | tar -zxvf horizon.tar.gz 12 | mv /horizon-v${HORIZON_VERSION}-linux-amd64/horizon /usr/local/bin 13 | chmod +x /usr/local/bin/horizon 14 | rm -rf horizon.tar.gz /horizon-v${HORIZON_VERSION}-linux-amd64 15 | 16 | echo "\nDone installing stellar-core and horizon...\n" 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | services: 3 | - docker 4 | env: 5 | - NETWORK=testnet 6 | - NETWORK=pubnet 7 | - TAG_TESTING=1 NETWORK=testnet 8 | - TAG_TESTING=1 NETWORK=pubnet 9 | language: go 10 | script: 11 | - | 12 | # Check if env `TAG_TESTING` has length equal to zero 13 | if [[ -z "${TAG_TESTING}" ]]; then 14 | docker build -t stellar-travis . 15 | else 16 | docker build -f Dockerfile.testing -t stellar-travis . 17 | fi 18 | 19 | docker run --rm -d -p "8000:8000" --name stellar stellar-travis --$NETWORK 20 | 21 | sleep 10 # sleep until supervisor is up 22 | echo "supervisorctl tail -f stellar-core" | docker exec -i stellar sh & 23 | go run travis.go 24 | -------------------------------------------------------------------------------- /standalone/core/etc/stellar-core.cfg: -------------------------------------------------------------------------------- 1 | # simple configuration for a standalone test "network" 2 | # see stellar-core_example.cfg for a description of the configuration parameters 3 | 4 | HTTP_PORT=11626 5 | PUBLIC_HTTP_PORT=true 6 | RUN_STANDALONE=true 7 | 8 | NETWORK_PASSPHRASE="Standalone Network ; February 2017" 9 | KNOWN_CURSORS=["HORIZON"] 10 | NODE_SEED="SDQVDISRYN2JXBS7ICL7QJAEKB3HWBJFP2QECXG7GZICAHBK4UNJCWK2 self" 11 | NODE_IS_VALIDATOR=true 12 | 13 | #DATABASE="postgresql://dbname=stellar user=postgres password=password host=localhost" 14 | #DATABASE="sqlite3://stellar.db" 15 | DATABASE="postgresql://dbname=core host=localhost user=stellar password=__PGPASS__" 16 | 17 | COMMANDS=["ll?level=debug"] 18 | 19 | FAILURE_SAFETY=0 20 | UNSAFE_QUORUM=true 21 | #The public keys of the Stellar testnet servers 22 | [QUORUM_SET] 23 | THRESHOLD_PERCENT=100 24 | VALIDATORS=["$self"] 25 | 26 | [HISTORY.vs] 27 | get="cp /tmp/stellar-core/history/vs/{0} {1}" 28 | put="cp {0} /tmp/stellar-core/history/vs/{1}" 29 | mkdir="mkdir -p /tmp/stellar-core/history/vs/{0}" -------------------------------------------------------------------------------- /common/supervisor/etc/supervisord.conf: -------------------------------------------------------------------------------- 1 | [unix_http_server] 2 | file=/var/run/supervisor.sock 3 | chmod=0700 4 | 5 | [supervisord] 6 | logfile=/var/log/supervisor/supervisord.log 7 | pidfile=/var/run/supervisord.pid 8 | childlogdir=/var/log/supervisor 9 | 10 | [rpcinterface:supervisor] 11 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 12 | 13 | [supervisorctl] 14 | serverurl=unix:///var/run/supervisor.sock 15 | 16 | [program:postgresql] 17 | user=postgres 18 | command=/usr/lib/postgresql/9.6/bin/postgres -D "/opt/stellar/postgresql/data" -c config_file=/opt/stellar/postgresql/etc/postgresql.conf 19 | stopsignal=INT 20 | autostart=true 21 | autorestart=true 22 | priority=10 23 | 24 | [program:stellar-core] 25 | user=stellar 26 | directory=/opt/stellar/core 27 | command=/opt/stellar/core/bin/start 28 | autostart=true 29 | autorestart=true 30 | priority=20 31 | 32 | [program:horizon] 33 | user=stellar 34 | directory=/opt/stellar/horizon 35 | command=/opt/stellar/horizon/bin/start 36 | autostart=true 37 | autorestart=true 38 | priority=30 39 | -------------------------------------------------------------------------------- /travis.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "log" 6 | "net/http" 7 | "os" 8 | "time" 9 | ) 10 | 11 | const timeout = 1 * time.Hour 12 | 13 | type Root struct { 14 | HorizonSequence int32 `json:"history_latest_ledger"` 15 | CoreSequence int32 `json:"core_latest_ledger"` 16 | } 17 | 18 | func main() { 19 | startTime := time.Now() 20 | 21 | for { 22 | time.Sleep(10 * time.Second) 23 | logLine("Waiting for Horizon to start ingesting") 24 | 25 | if time.Since(startTime) > timeout { 26 | logLine("Timeout") 27 | os.Exit(-1) 28 | } 29 | 30 | resp, err := http.Get("http://localhost:8000") 31 | if err != nil { 32 | logLine(err) 33 | continue 34 | } 35 | 36 | var root Root 37 | decoder := json.NewDecoder(resp.Body) 38 | err = decoder.Decode(&root) 39 | if err != nil { 40 | logLine(err) 41 | continue 42 | } 43 | 44 | if root.HorizonSequence > 0 { 45 | logLine("Horizon started ingesting!") 46 | os.Exit(0) 47 | } 48 | } 49 | } 50 | 51 | func logLine(text interface{}) { 52 | log.Println("\033[32;1m[test]\033[0m", text) 53 | } 54 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM stellar/base:latest 2 | 3 | MAINTAINER Bartek Nowotarski 4 | 5 | ENV STELLAR_CORE_VERSION 13.1.0-1237-469b2e70 6 | ENV HORIZON_VERSION 1.4.0 7 | 8 | EXPOSE 5432 9 | EXPOSE 8000 10 | EXPOSE 11625 11 | EXPOSE 11626 12 | 13 | ADD dependencies / 14 | RUN ["chmod", "+x", "dependencies"] 15 | RUN /dependencies 16 | 17 | ADD install / 18 | RUN ["chmod", "+x", "install"] 19 | RUN /install 20 | 21 | RUN ["mkdir", "-p", "/opt/stellar"] 22 | RUN ["touch", "/opt/stellar/.docker-ephemeral"] 23 | 24 | RUN useradd --uid 10011001 --home-dir /home/stellar --no-log-init stellar \ 25 | && mkdir -p /home/stellar \ 26 | && chown -R stellar:stellar /home/stellar 27 | 28 | RUN ["ln", "-s", "/opt/stellar", "/stellar"] 29 | RUN ["ln", "-s", "/opt/stellar/core/etc/stellar-core.cfg", "/stellar-core.cfg"] 30 | RUN ["ln", "-s", "/opt/stellar/horizon/etc/horizon.env", "/horizon.env"] 31 | ADD common /opt/stellar-default/common 32 | ADD pubnet /opt/stellar-default/pubnet 33 | ADD testnet /opt/stellar-default/testnet 34 | ADD standalone /opt/stellar-default/standalone 35 | 36 | 37 | ADD start / 38 | RUN ["chmod", "+x", "start"] 39 | 40 | ENTRYPOINT ["/init", "--", "/start" ] 41 | -------------------------------------------------------------------------------- /Dockerfile.testing: -------------------------------------------------------------------------------- 1 | FROM stellar/base:latest 2 | 3 | MAINTAINER Bartek Nowotarski 4 | 5 | ENV STELLAR_CORE_VERSION 13.1.0-1237-469b2e70 6 | ENV HORIZON_VERSION 1.4.0 7 | 8 | EXPOSE 5432 9 | EXPOSE 8000 10 | EXPOSE 11625 11 | EXPOSE 11626 12 | 13 | ADD dependencies / 14 | RUN ["chmod", "+x", "dependencies"] 15 | RUN /dependencies 16 | 17 | ADD install / 18 | RUN ["chmod", "+x", "install"] 19 | RUN /install 20 | 21 | RUN ["mkdir", "-p", "/opt/stellar"] 22 | RUN ["touch", "/opt/stellar/.docker-ephemeral"] 23 | 24 | RUN useradd --uid 10011001 --home-dir /home/stellar --no-log-init stellar \ 25 | && mkdir -p /home/stellar \ 26 | && chown -R stellar:stellar /home/stellar 27 | 28 | RUN ["ln", "-s", "/opt/stellar", "/stellar"] 29 | RUN ["ln", "-s", "/opt/stellar/core/etc/stellar-core.cfg", "/stellar-core.cfg"] 30 | RUN ["ln", "-s", "/opt/stellar/horizon/etc/horizon.env", "/horizon.env"] 31 | ADD common /opt/stellar-default/common 32 | ADD pubnet /opt/stellar-default/pubnet 33 | ADD testnet /opt/stellar-default/testnet 34 | ADD standalone /opt/stellar-default/standalone 35 | 36 | 37 | ADD start / 38 | RUN ["chmod", "+x", "start"] 39 | 40 | ENTRYPOINT ["/init", "--", "/start" ] 41 | -------------------------------------------------------------------------------- /testnet/core/etc/stellar-core.cfg: -------------------------------------------------------------------------------- 1 | HTTP_PORT=11626 2 | PUBLIC_HTTP_PORT=true 3 | LOG_FILE_PATH="" 4 | 5 | NETWORK_PASSPHRASE="Test SDF Network ; September 2015" 6 | KNOWN_CURSORS=["HORIZON"] 7 | DATABASE="postgresql://dbname=core host=localhost user=stellar password=__PGPASS__" 8 | UNSAFE_QUORUM=true 9 | FAILURE_SAFETY=1 10 | CATCHUP_RECENT=100 11 | 12 | [HISTORY.cache] 13 | get="cp /opt/stellar/history-cache/{0} {1}" 14 | 15 | [[HOME_DOMAINS]] 16 | HOME_DOMAIN="testnet.stellar.org" 17 | QUALITY="HIGH" 18 | 19 | [[VALIDATORS]] 20 | NAME="sdf_testnet_1" 21 | HOME_DOMAIN="testnet.stellar.org" 22 | PUBLIC_KEY="GDKXE2OZMJIPOSLNA6N6F2BVCI3O777I2OOC4BV7VOYUEHYX7RTRYA7Y" 23 | ADDRESS="core-testnet1.stellar.org" 24 | HISTORY="curl -sf http://history.stellar.org/prd/core-testnet/core_testnet_001/{0} -o {1}" 25 | 26 | [[VALIDATORS]] 27 | NAME="sdf_testnet_2" 28 | HOME_DOMAIN="testnet.stellar.org" 29 | PUBLIC_KEY="GCUCJTIYXSOXKBSNFGNFWW5MUQ54HKRPGJUTQFJ5RQXZXNOLNXYDHRAP" 30 | ADDRESS="core-testnet2.stellar.org" 31 | HISTORY="curl -sf http://history.stellar.org/prd/core-testnet/core_testnet_002/{0} -o {1}" 32 | 33 | [[VALIDATORS]] 34 | NAME="sdf_testnet_3" 35 | HOME_DOMAIN="testnet.stellar.org" 36 | PUBLIC_KEY="GC2V2EFSXN6SQTWVYA5EPJPBWWIMSD2XQNKUOHGEKB535AQE2I6IXV2Z" 37 | ADDRESS="core-testnet3.stellar.org" 38 | HISTORY="curl -sf http://history.stellar.org/prd/core-testnet/core_testnet_003/{0} -o {1}" 39 | -------------------------------------------------------------------------------- /common/postgresql/etc/pg_ident.conf: -------------------------------------------------------------------------------- 1 | # PostgreSQL User Name Maps 2 | # ========================= 3 | # 4 | # Refer to the PostgreSQL documentation, chapter "Client 5 | # Authentication" for a complete description. A short synopsis 6 | # follows. 7 | # 8 | # This file controls PostgreSQL user name mapping. It maps external 9 | # user names to their corresponding PostgreSQL user names. Records 10 | # are of the form: 11 | # 12 | # MAPNAME SYSTEM-USERNAME PG-USERNAME 13 | # 14 | # (The uppercase quantities must be replaced by actual values.) 15 | # 16 | # MAPNAME is the (otherwise freely chosen) map name that was used in 17 | # pg_hba.conf. SYSTEM-USERNAME is the detected user name of the 18 | # client. PG-USERNAME is the requested PostgreSQL user name. The 19 | # existence of a record specifies that SYSTEM-USERNAME may connect as 20 | # PG-USERNAME. 21 | # 22 | # If SYSTEM-USERNAME starts with a slash (/), it will be treated as a 23 | # regular expression. Optionally this can contain a capture (a 24 | # parenthesized subexpression). The substring matching the capture 25 | # will be substituted for \1 (backslash-one) if present in 26 | # PG-USERNAME. 27 | # 28 | # Multiple maps may be specified in this file and used by pg_hba.conf. 29 | # 30 | # No map names are defined in the default configuration. If all 31 | # system user names and PostgreSQL user names are the same, you don't 32 | # need anything in this file. 33 | # 34 | # This file is read on server startup and when the postmaster receives 35 | # a SIGHUP signal. If you edit the file on a running system, you have 36 | # to SIGHUP the postmaster for the changes to take effect. You can 37 | # use "pg_ctl reload" to do that. 38 | 39 | # Put your actual configuration here 40 | # ---------------------------------- 41 | 42 | # MAPNAME SYSTEM-USERNAME PG-USERNAME 43 | -------------------------------------------------------------------------------- /common/postgresql/etc/pg_hba.conf: -------------------------------------------------------------------------------- 1 | # PostgreSQL Client Authentication Configuration File 2 | # =================================================== 3 | # 4 | # Refer to the "Client Authentication" section in the PostgreSQL 5 | # documentation for a complete description of this file. A short 6 | # synopsis follows. 7 | # 8 | # This file controls: which hosts are allowed to connect, how clients 9 | # are authenticated, which PostgreSQL user names they can use, which 10 | # databases they can access. Records take one of these forms: 11 | # 12 | # local DATABASE USER METHOD [OPTIONS] 13 | # host DATABASE USER ADDRESS METHOD [OPTIONS] 14 | # hostssl DATABASE USER ADDRESS METHOD [OPTIONS] 15 | # hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] 16 | # 17 | # (The uppercase items must be replaced by actual values.) 18 | # 19 | # The first field is the connection type: "local" is a Unix-domain 20 | # socket, "host" is either a plain or SSL-encrypted TCP/IP socket, 21 | # "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a 22 | # plain TCP/IP socket. 23 | # 24 | # DATABASE can be "all", "sameuser", "samerole", "replication", a 25 | # database name, or a comma-separated list thereof. The "all" 26 | # keyword does not match "replication". Access to replication 27 | # must be enabled in a separate record (see example below). 28 | # 29 | # USER can be "all", a user name, a group name prefixed with "+", or a 30 | # comma-separated list thereof. In both the DATABASE and USER fields 31 | # you can also write a file name prefixed with "@" to include names 32 | # from a separate file. 33 | # 34 | # ADDRESS specifies the set of hosts the record matches. It can be a 35 | # host name, or it is made up of an IP address and a CIDR mask that is 36 | # an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that 37 | # specifies the number of significant bits in the mask. A host name 38 | # that starts with a dot (.) matches a suffix of the actual host name. 39 | # Alternatively, you can write an IP address and netmask in separate 40 | # columns to specify the set of hosts. Instead of a CIDR-address, you 41 | # can write "samehost" to match any of the server's own IP addresses, 42 | # or "samenet" to match any address in any subnet that the server is 43 | # directly connected to. 44 | # 45 | # METHOD can be "trust", "reject", "md5", "password", "gss", "sspi", 46 | # "ident", "peer", "pam", "ldap", "radius" or "cert". Note that 47 | # "password" sends passwords in clear text; "md5" is preferred since 48 | # it sends encrypted passwords. 49 | # 50 | # OPTIONS are a set of options for the authentication in the format 51 | # NAME=VALUE. The available options depend on the different 52 | # authentication methods -- refer to the "Client Authentication" 53 | # section in the documentation for a list of which options are 54 | # available for which authentication methods. 55 | # 56 | # Database and user names containing spaces, commas, quotes and other 57 | # special characters must be quoted. Quoting one of the keywords 58 | # "all", "sameuser", "samerole" or "replication" makes the name lose 59 | # its special character, and just match a database or username with 60 | # that name. 61 | # 62 | # This file is read on server startup and when the postmaster receives 63 | # a SIGHUP signal. If you edit the file on a running system, you have 64 | # to SIGHUP the postmaster for the changes to take effect. You can 65 | # use "pg_ctl reload" to do that. 66 | 67 | # Put your actual configuration here 68 | # ---------------------------------- 69 | # 70 | # If you want to allow non-local connections, you need to add more 71 | # "host" records. In that case you will also need to make PostgreSQL 72 | # listen on a non-local interface via the listen_addresses 73 | # configuration parameter, or via the -i or -h command line switches. 74 | 75 | 76 | 77 | 78 | # DO NOT DISABLE! 79 | # If you change this first entry you will need to make sure that the 80 | # database superuser can access the database using some other method. 81 | # Noninteractive access to all databases is required during automatic 82 | # maintenance (custom daily cronjobs, replication, and similar tasks). 83 | # 84 | # Database administrative login by Unix domain socket 85 | local all postgres peer 86 | 87 | # TYPE DATABASE USER ADDRESS METHOD 88 | 89 | # "local" is for Unix domain socket connections only 90 | local all all md5 91 | # IPv4 local connections: 92 | host all all 127.0.0.1/32 md5 93 | host all all 0.0.0.0/0 md5 94 | # IPv6 local connections: 95 | host all all ::1/128 md5 96 | # Allow replication connections from localhost, by a user with the 97 | # replication privilege. 98 | #local replication postgres peer 99 | #host replication postgres 127.0.0.1/32 md5 100 | #host replication postgres ::1/128 md5 101 | -------------------------------------------------------------------------------- /pubnet/core/etc/stellar-core.cfg: -------------------------------------------------------------------------------- 1 | HTTP_PORT=11626 2 | PUBLIC_HTTP_PORT=true 3 | LOG_FILE_PATH="" 4 | 5 | DATABASE="postgresql://dbname=core host=localhost user=stellar password=__PGPASS__" 6 | NETWORK_PASSPHRASE="Public Global Stellar Network ; September 2015" 7 | KNOWN_CURSORS=["HORIZON"] 8 | CATCHUP_RECENT=100 9 | 10 | [HISTORY.cache] 11 | get="cp /opt/stellar/history-cache/{0} {1}" 12 | 13 | [[HOME_DOMAINS]] 14 | HOME_DOMAIN="stellar.org" 15 | QUALITY="HIGH" 16 | 17 | [[HOME_DOMAINS]] 18 | HOME_DOMAIN="satoshipay.io" 19 | QUALITY="HIGH" 20 | 21 | [[HOME_DOMAINS]] 22 | HOME_DOMAIN="lobstr.co" 23 | QUALITY="HIGH" 24 | 25 | [[HOME_DOMAINS]] 26 | HOME_DOMAIN="www.coinqvest.com" 27 | QUALITY="HIGH" 28 | 29 | [[HOME_DOMAINS]] 30 | HOME_DOMAIN="keybase.io" 31 | QUALITY="HIGH" 32 | 33 | [[HOME_DOMAINS]] 34 | HOME_DOMAIN="stellar.blockdaemon.com" 35 | QUALITY="HIGH" 36 | 37 | [[HOME_DOMAINS]] 38 | HOME_DOMAIN="wirexapp.com" 39 | QUALITY="HIGH" 40 | 41 | [[VALIDATORS]] 42 | NAME="sdf_1" 43 | HOME_DOMAIN="stellar.org" 44 | PUBLIC_KEY="GCGB2S2KGYARPVIA37HYZXVRM2YZUEXA6S33ZU5BUDC6THSB62LZSTYH" 45 | ADDRESS="core-live-a.stellar.org:11625" 46 | HISTORY="curl -sf https://history.stellar.org/prd/core-live/core_live_001/{0} -o {1}" 47 | 48 | [[VALIDATORS]] 49 | NAME="sdf_2" 50 | HOME_DOMAIN="stellar.org" 51 | PUBLIC_KEY="GCM6QMP3DLRPTAZW2UZPCPX2LF3SXWXKPMP3GKFZBDSF3QZGV2G5QSTK" 52 | ADDRESS="core-live-b.stellar.org:11625" 53 | HISTORY="curl -sf https://history.stellar.org/prd/core-live/core_live_002/{0} -o {1}" 54 | 55 | [[VALIDATORS]] 56 | NAME="sdf_3" 57 | HOME_DOMAIN="stellar.org" 58 | PUBLIC_KEY="GABMKJM6I25XI4K7U6XWMULOUQIQ27BCTMLS6BYYSOWKTBUXVRJSXHYQ" 59 | ADDRESS="core-live-c.stellar.org:11625" 60 | HISTORY="curl -sf https://history.stellar.org/prd/core-live/core_live_003/{0} -o {1}" 61 | 62 | [[VALIDATORS]] 63 | NAME="satoshipay_singapore" 64 | HOME_DOMAIN="satoshipay.io" 65 | PUBLIC_KEY="GBJQUIXUO4XSNPAUT6ODLZUJRV2NPXYASKUBY4G5MYP3M47PCVI55MNT" 66 | ADDRESS="stellar-sg-sin.satoshipay.io:11625" 67 | HISTORY="curl -sf https://stellar-history-sg-sin.satoshipay.io/{0} -o {1}" 68 | 69 | [[VALIDATORS]] 70 | NAME="satoshipay_iowa" 71 | HOME_DOMAIN="satoshipay.io" 72 | PUBLIC_KEY="GAK6Z5UVGUVSEK6PEOCAYJISTT5EJBB34PN3NOLEQG2SUKXRVV2F6HZY" 73 | ADDRESS="stellar-us-iowa.satoshipay.io:11625" 74 | HISTORY="curl -sf https://stellar-history-us-iowa.satoshipay.io/{0} -o {1}" 75 | 76 | [[VALIDATORS]] 77 | NAME="satoshipay_frankfurt" 78 | HOME_DOMAIN="satoshipay.io" 79 | PUBLIC_KEY="GC5SXLNAM3C4NMGK2PXK4R34B5GNZ47FYQ24ZIBFDFOCU6D4KBN4POAE" 80 | ADDRESS="stellar-de-fra.satoshipay.io:11625" 81 | HISTORY="curl -sf https://stellar-history-de-fra.satoshipay.io/{0} -o {1}" 82 | 83 | [[VALIDATORS]] 84 | NAME="lobstr_1_europe" 85 | HOME_DOMAIN="lobstr.co" 86 | PUBLIC_KEY="GCFONE23AB7Y6C5YZOMKUKGETPIAJA4QOYLS5VNS4JHBGKRZCPYHDLW7" 87 | ADDRESS="v1.stellar.lobstr.co:11625" 88 | HISTORY="curl -sf https://stellar-archive-1-lobstr.s3.amazonaws.com/{0} -o {1}" 89 | 90 | [[VALIDATORS]] 91 | NAME="lobstr_2_europe" 92 | HOME_DOMAIN="lobstr.co" 93 | PUBLIC_KEY="GDXQB3OMMQ6MGG43PWFBZWBFKBBDUZIVSUDAZZTRAWQZKES2CDSE5HKJ" 94 | ADDRESS="v2.stellar.lobstr.co:11625" 95 | HISTORY="curl -sf https://stellar-archive-2-lobstr.s3.amazonaws.com/{0} -o {1}" 96 | 97 | [[VALIDATORS]] 98 | NAME="lobstr_3_north_america" 99 | HOME_DOMAIN="lobstr.co" 100 | PUBLIC_KEY="GD5QWEVV4GZZTQP46BRXV5CUMMMLP4JTGFD7FWYJJWRL54CELY6JGQ63" 101 | ADDRESS="v3.stellar.lobstr.co:11625" 102 | HISTORY="curl -sf https://stellar-archive-3-lobstr.s3.amazonaws.com/{0} -o {1}" 103 | 104 | [[VALIDATORS]] 105 | NAME="lobstr_4_asia" 106 | HOME_DOMAIN="lobstr.co" 107 | PUBLIC_KEY="GA7TEPCBDQKI7JQLQ34ZURRMK44DVYCIGVXQQWNSWAEQR6KB4FMCBT7J" 108 | ADDRESS="v4.stellar.lobstr.co:11625" 109 | HISTORY="curl -sf https://stellar-archive-4-lobstr.s3.amazonaws.com/{0} -o {1}" 110 | 111 | [[VALIDATORS]] 112 | NAME="lobstr_5_australia" 113 | HOME_DOMAIN="lobstr.co" 114 | PUBLIC_KEY="GA5STBMV6QDXFDGD62MEHLLHZTPDI77U3PFOD2SELU5RJDHQWBR5NNK7" 115 | ADDRESS="v5.stellar.lobstr.co:11625" 116 | HISTORY="curl -sf https://stellar-archive-5-lobstr.s3.amazonaws.com/{0} -o {1}" 117 | 118 | [[VALIDATORS]] 119 | NAME="coinqvest_hong_kong" 120 | HOME_DOMAIN="www.coinqvest.com" 121 | PUBLIC_KEY="GAZ437J46SCFPZEDLVGDMKZPLFO77XJ4QVAURSJVRZK2T5S7XUFHXI2Z" 122 | ADDRESS="hongkong.stellar.coinqvest.com:11625" 123 | HISTORY="curl -sf https://hongkong.stellar.coinqvest.com/history/{0} -o {1}" 124 | 125 | [[VALIDATORS]] 126 | NAME="coinqvest_germany" 127 | HOME_DOMAIN="www.coinqvest.com" 128 | PUBLIC_KEY="GD6SZQV3WEJUH352NTVLKEV2JM2RH266VPEM7EH5QLLI7ZZAALMLNUVN" 129 | ADDRESS="germany.stellar.coinqvest.com:11625" 130 | HISTORY="curl -sf https://germany.stellar.coinqvest.com/history/{0} -o {1}" 131 | 132 | [[VALIDATORS]] 133 | NAME="coinqvest_finland" 134 | HOME_DOMAIN="www.coinqvest.com" 135 | PUBLIC_KEY="GADLA6BJK6VK33EM2IDQM37L5KGVCY5MSHSHVJA4SCNGNUIEOTCR6J5T" 136 | ADDRESS="finland.stellar.coinqvest.com:11625" 137 | HISTORY="curl -sf https://finland.stellar.coinqvest.com/history/{0} -o {1}" 138 | 139 | [[VALIDATORS]] 140 | NAME="keybase_io" 141 | HOME_DOMAIN="keybase.io" 142 | PUBLIC_KEY="GCWJKM4EGTGJUVSWUJDPCQEOEP5LHSOFKSA4HALBTOO4T4H3HCHOM6UX" 143 | ADDRESS="stellar0.keybase.io:11625" 144 | HISTORY="curl -sf https://stellarhistory.keybase.io/{0} -o {1}" 145 | 146 | [[VALIDATORS]] 147 | NAME="keybase_1" 148 | HOME_DOMAIN="keybase.io" 149 | PUBLIC_KEY="GDKWELGJURRKXECG3HHFHXMRX64YWQPUHKCVRESOX3E5PM6DM4YXLZJM" 150 | ADDRESS="stellar1.keybase.io:11625" 151 | HISTORY="curl -sf https://stellarhistory1.keybase.io/{0} -o {1}" 152 | 153 | [[VALIDATORS]] 154 | NAME="keybase_2" 155 | HOME_DOMAIN="keybase.io" 156 | PUBLIC_KEY="GA35T3723UP2XJLC2H7MNL6VMKZZIFL2VW7XHMFFJKKIA2FJCYTLKFBW" 157 | ADDRESS="stellar2.keybase.io:11625" 158 | HISTORY="curl -sf https://stellarhistory2.keybase.io/{0} -o {1}" 159 | 160 | [[VALIDATORS]] 161 | NAME="Blockdaemon_Validator_1" 162 | HOME_DOMAIN="stellar.blockdaemon.com" 163 | PUBLIC_KEY="GAAV2GCVFLNN522ORUYFV33E76VPC22E72S75AQ6MBR5V45Z5DWVPWEU" 164 | ADDRESS="stellar-full-validator1.bdnodes.net" 165 | HISTORY="curl -sf https://stellar-full-history1.bdnodes.net/{0} -o {1}" 166 | 167 | [[VALIDATORS]] 168 | NAME="Blockdaemon_Validator_2" 169 | HOME_DOMAIN="stellar.blockdaemon.com" 170 | PUBLIC_KEY="GAVXB7SBJRYHSG6KSQHY74N7JAFRL4PFVZCNWW2ARI6ZEKNBJSMSKW7C" 171 | ADDRESS="stellar-full-validator2.bdnodes.net" 172 | HISTORY="curl -sf https://stellar-full-history2.bdnodes.net/{0} -o {1}" 173 | 174 | [[VALIDATORS]] 175 | NAME="Blockdaemon_Validator_3" 176 | HOME_DOMAIN="stellar.blockdaemon.com" 177 | PUBLIC_KEY="GAYXZ4PZ7P6QOX7EBHPIZXNWY4KCOBYWJCA4WKWRKC7XIUS3UJPT6EZ4" 178 | ADDRESS="stellar-full-validator3.bdnodes.net" 179 | HISTORY="curl -sf https://stellar-full-history3.bdnodes.net/{0} -o {1}" 180 | 181 | [[VALIDATORS]] 182 | NAME="wirexUS" 183 | ADDRESS="us.stellar.wirexapp.com" 184 | HOME_DOMAIN="wirexapp.com" 185 | PUBLIC_KEY="GDXUKFGG76WJC7ACEH3JUPLKM5N5S76QSMNDBONREUXPCZYVPOLFWXUS" 186 | HISTORY="curl -sf http://wxhorizonusstga1.blob.core.windows.net/history/{0} -o {1}" 187 | 188 | [[VALIDATORS]] 189 | NAME="wirexUK" 190 | ADDRESS="uk.stellar.wirexapp.com" 191 | HOME_DOMAIN="wirexapp.com" 192 | PUBLIC_KEY="GBBQQT3EIUSXRJC6TGUCGVA3FVPXVZLGG3OJYACWBEWYBHU46WJLWXEU" 193 | HISTORY="curl -sf http://wxhorizonukstga1.blob.core.windows.net/history/{0} -o {1}" 194 | 195 | [[VALIDATORS]] 196 | NAME="wirexSG" 197 | ADDRESS="sg.stellar.wirexapp.com" 198 | HOME_DOMAIN="wirexapp.com" 199 | PUBLIC_KEY="GAB3GZIE6XAYWXGZUDM4GMFFLJBFMLE2JDPUCWUZXMOMT3NHXDHEWXAS" 200 | HISTORY="curl -sf http://wxhorizonasiastga1.blob.core.windows.net/history/{0} -o {1}" 201 | -------------------------------------------------------------------------------- /start: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | set -e 3 | 4 | export STELLAR_HOME="/opt/stellar" 5 | export PGHOME="$STELLAR_HOME/postgresql" 6 | export SUPHOME="$STELLAR_HOME/supervisor" 7 | export COREHOME="$STELLAR_HOME/core" 8 | export HZHOME="$STELLAR_HOME/horizon" 9 | 10 | export PGBIN="/usr/lib/postgresql/9.6/bin" 11 | export PGDATA="$PGHOME/data" 12 | export PGUSER="stellar" 13 | export PGPORT=5432 14 | 15 | QUICKSTART_INITIALIZED=false 16 | CURRENT_POSTGRES_PID="" 17 | 18 | function main() { 19 | echo "" 20 | echo "Starting Stellar Quickstart" 21 | echo "" 22 | 23 | process_args $* 24 | 25 | echo "mode: $STELLAR_MODE" 26 | echo "network: $NETWORK ($NETWORK_PASSPHRASE)" 27 | 28 | copy_defaults 29 | init_db 30 | init_stellar_core 31 | init_horizon 32 | copy_pgpass 33 | 34 | stop_postgres # this gets started in init_db 35 | 36 | # launch services 37 | exec_supervisor 38 | } 39 | 40 | function process_args() { 41 | while [[ -n "$1" ]]; do 42 | ARG="$1" 43 | shift 44 | 45 | 46 | case "${ARG}" in 47 | --testnet) 48 | NETWORK="testnet" 49 | ;; 50 | --pubnet) 51 | NETWORK="pubnet" 52 | ;; 53 | --standalone) 54 | NETWORK="standalone" 55 | ;; 56 | --protocol-version) 57 | export PROTOCOL_VERSION="$1" 58 | shift 59 | ;; 60 | --enable-asset-stats) 61 | export ENABLE_ASSET_STATS="$1" 62 | shift 63 | ;; 64 | *) 65 | echo "Unknown container arg $ARG" >&2 66 | exit 1 67 | esac 68 | done 69 | 70 | # TODO: ask for what network to use 71 | if [ -z "$NETWORK" ]; then 72 | NETWORK="testnet" 73 | fi 74 | 75 | case "$NETWORK" in 76 | testnet) 77 | export NETWORK_PASSPHRASE="Test SDF Network ; September 2015" 78 | export HISTORY_ARCHIVE_URLS="https://history.stellar.org/prd/core-testnet/core_testnet_001" 79 | ;; 80 | pubnet) 81 | export NETWORK_PASSPHRASE="Public Global Stellar Network ; September 2015" 82 | export HISTORY_ARCHIVE_URLS="https://history.stellar.org/prd/core-live/core_live_001" 83 | ;; 84 | standalone) 85 | export NETWORK_PASSPHRASE="Standalone Network ; February 2017" 86 | # h1570ry - we'll start a webserver connected to history directory later on 87 | export HISTORY_ARCHIVE_URLS="http://localhost:1570" 88 | ;; 89 | *) 90 | echo "Unknown network: '$NETWORK'" >&2 91 | exit 1 92 | esac 93 | 94 | # Are we ephemeral or persistent? 95 | if [ -z "$STELLAR_MODE" ]; then 96 | if [ -f "/opt/stellar/.docker-ephemeral" ]; then 97 | STELLAR_MODE="ephemeral" 98 | else 99 | STELLAR_MODE="persistent" 100 | fi 101 | fi 102 | } 103 | 104 | function set_pg_password() { 105 | 106 | if [ -n "$POSTGRES_PASSWORD" ]; then 107 | PGPASS=$POSTGRES_PASSWORD 108 | echo "using POSTGRES_PASSWORD" 109 | return 0 110 | fi 111 | 112 | # use a random password when ephemeral (or some other unknown mode) 113 | if [ "$STELLAR_MODE" != "persistent" ]; then 114 | PGPASS=$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 16) 115 | echo "postgres password: $PGPASS" 116 | return 0 117 | fi 118 | 119 | if [ -n "$PGPASS" ]; then 120 | echo "postgres password: $PGPASS" 121 | return 0 122 | fi 123 | 124 | # ask for a password when persistent 125 | read -s -p "Enter New Postgresql Password: " PGPASS 126 | echo "" 127 | read -s -p "Confirm: " PGPASS_CONFIRMATION 128 | echo "" 129 | 130 | if [ -z "$PGPASS" ]; then 131 | echo "Password empty" >&2 132 | exit 1 133 | fi 134 | 135 | if [ "$PGPASS" != "$PGPASS_CONFIRMATION" ]; then 136 | echo "Password mistmach" >&2 137 | exit 1 138 | fi 139 | 140 | } 141 | 142 | function copy_defaults() { 143 | local CP="rsync -a" 144 | 145 | if [ -d $PGHOME/etc ]; then 146 | echo "postgres: config directory exists, skipping copy" 147 | else 148 | $CP /opt/stellar-default/common/postgresql/ $PGHOME 149 | fi 150 | 151 | if [ -d $SUPHOME/etc ]; then 152 | echo "supervisor: config directory exists, skipping copy" 153 | else 154 | $CP /opt/stellar-default/common/supervisor/ $SUPHOME 155 | fi 156 | 157 | if [ -d $COREHOME/etc ]; then 158 | echo "stellar-core: config directory exists, skipping copy" 159 | else 160 | $CP /opt/stellar-default/common/core/ $COREHOME 161 | $CP /opt/stellar-default/$NETWORK/core/ $COREHOME 162 | fi 163 | 164 | if [ -d $HZHOME/etc ]; then 165 | echo "horizon: config directory exists, skipping copy" 166 | else 167 | $CP /opt/stellar-default/common/horizon/ $HZHOME 168 | fi 169 | } 170 | 171 | function copy_pgpass() { 172 | local CP="rsync -a" 173 | 174 | $CP /opt/stellar/postgresql/.pgpass /root/ 175 | chmod 0600 /root/.pgpass 176 | 177 | $CP /opt/stellar/postgresql/.pgpass /home/stellar 178 | chmod 0600 /home/stellar/.pgpass 179 | chown stellar:stellar /home/stellar/.pgpass 180 | } 181 | 182 | function init_db() { 183 | if [ -f $PGHOME/.quickstart-initialized ]; then 184 | echo "postgres: already initialized" 185 | return 0 186 | fi 187 | pushd $PGHOME 188 | 189 | # workaround!!!! from: https://github.com/nimiq/docker-postgresql93/issues/2 190 | mkdir /etc/ssl/private-copy; mv /etc/ssl/private/* /etc/ssl/private-copy/; rm -r /etc/ssl/private; mv /etc/ssl/private-copy /etc/ssl/private; chmod -R 0700 /etc/ssl/private; chown -R postgres /etc/ssl/private 191 | # end workaround 192 | 193 | echo "postgres user: $PGUSER" 194 | 195 | set_pg_password 196 | 197 | run_silent "finalize-pgpass" sed -ri "s/__PGPASS__/$PGPASS/g" /opt/stellar/postgresql/.pgpass 198 | 199 | mkdir -p $PGDATA 200 | chown postgres:postgres $PGDATA 201 | chmod 0700 $PGDATA 202 | 203 | run_silent "init-postgres" sudo -u postgres $PGBIN/initdb -D $PGDATA 204 | 205 | start_postgres 206 | run_silent "create-horizon-db" sudo -u postgres createdb horizon 207 | run_silent "create-core-db" sudo -u postgres createdb core 208 | run_silent "stellar-postgres-user" sudo -u postgres psql <<-SQL 209 | CREATE USER $PGUSER WITH PASSWORD '$PGPASS'; 210 | GRANT ALL PRIVILEGES ON DATABASE horizon to $PGUSER; 211 | GRANT ALL PRIVILEGES ON DATABASE core to $PGUSER; 212 | SQL 213 | 214 | touch .quickstart-initialized 215 | popd 216 | } 217 | 218 | function init_stellar_core() { 219 | pushd $COREHOME 220 | run_silent "chown-core" chown -R stellar:stellar . 221 | if [ -f $COREHOME/.quickstart-initialized ]; then 222 | echo "core: already initialized" 223 | 224 | if [ "$NETWORK" == "standalone" ]; then 225 | start_postgres 226 | 227 | run_silent "init-core-scp" sudo -u stellar stellar-core force-scp --conf $COREHOME/etc/stellar-core.cfg 228 | fi 229 | 230 | return 0 231 | fi 232 | 233 | run_silent "finalize-core-config" sed -ri "s/__PGPASS__/$PGPASS/g" etc/stellar-core.cfg 234 | 235 | start_postgres 236 | 237 | run_silent "init-core-db" sudo -u stellar stellar-core new-db --conf etc/stellar-core.cfg 238 | 239 | if [ "$NETWORK" == "standalone" ]; then 240 | run_silent "init-core-scp" sudo -u stellar stellar-core force-scp --conf etc/stellar-core.cfg 241 | 242 | run_silent "init-history" sudo -u stellar stellar-core new-hist vs --conf $COREHOME/etc/stellar-core.cfg 243 | # Start local history server 244 | pushd /tmp/stellar-core/history/vs 245 | python3 -m http.server 1570 > /dev/null 2>&1 & 246 | popd 247 | fi 248 | 249 | touch .quickstart-initialized 250 | popd 251 | } 252 | 253 | function init_horizon() { 254 | if [ -f $HZHOME/.quickstart-initialized ]; then 255 | echo "horizon: already initialized" 256 | return 0 257 | fi 258 | pushd $HZHOME 259 | 260 | run_silent "chown-horizon" chown stellar:stellar . 261 | 262 | sed -ri \ 263 | -e "s/__PGPASS__/$PGPASS/g" \ 264 | -e "s/__NETWORK__/$NETWORK_PASSPHRASE/g" \ 265 | -e "s=__ARCHIVE__=$HISTORY_ARCHIVE_URLS=g" \ 266 | etc/horizon.env 267 | 268 | start_postgres 269 | run_silent "init-horizon-db" sudo -u stellar ./bin/horizon db init 270 | 271 | touch .quickstart-initialized 272 | popd 273 | } 274 | 275 | function upgrade_standalone() { 276 | # Upgrade standalone network's protocol version 277 | if [ "$NETWORK" = "standalone" ]; then 278 | # Wait for server 279 | while ! echo "Stellar-core http server listening!" | nc localhost 11626 &> /dev/null; do sleep 1; done 280 | if [ -z "$PROTOCOL_VERSION" ]; then 281 | # default to latest version supported by core 282 | export PROTOCOL_VERSION=`curl -s http://localhost:11626/info | jq -r '.info.protocol_version'` 283 | fi 284 | if [ ".$PROTOCOL_VERSION" != ".none" ] ; then 285 | if [ $PROTOCOL_VERSION -gt 0 ]; then 286 | curl "http://localhost:11626/upgrades?mode=set&upgradetime=1970-01-01T00:00:00Z&protocolversion=$PROTOCOL_VERSION" 287 | fi 288 | fi 289 | fi 290 | } 291 | 292 | function exec_supervisor() { 293 | echo "starting supervisor" 294 | upgrade_standalone & 295 | exec supervisord -n -c $SUPHOME/etc/supervisord.conf 296 | } 297 | 298 | # run_silent is a utility function that runs a command with an abbreviated 299 | # output provided it succeeds. 300 | function run_silent() { 301 | local LABEL=$1 302 | shift 303 | local COMMAND=$1 304 | shift 305 | local ARGS=$@ 306 | local OUTFILE="/tmp/run_silent.out" 307 | 308 | echo -n "$LABEL: " 309 | set +e 310 | 311 | $COMMAND $ARGS &> $OUTFILE 312 | 313 | if [ $? -eq 0 ]; then 314 | echo "ok" 315 | else 316 | echo "failed!" 317 | echo "" 318 | cat $OUTFILE 319 | exit 1 320 | fi 321 | 322 | set -e 323 | } 324 | 325 | function start_postgres() { 326 | if [ ! -z "$CURRENT_POSTGRES_PID" ]; then 327 | return 0 328 | fi 329 | 330 | sudo -u postgres $PGBIN/postgres -D $PGDATA -c config_file=$PGHOME/etc/postgresql.conf &> /dev/null & 331 | CURRENT_POSTGRES_PID=$! 332 | 333 | while ! sudo -u postgres psql -c 'select 1' &> /dev/null ; do 334 | echo "Waiting for postgres to be available..." 335 | sleep 1 336 | done 337 | 338 | echo "postgres: up" 339 | } 340 | 341 | function stop_postgres() { 342 | if [ -z "$CURRENT_POSTGRES_PID" ]; then 343 | return 0 344 | fi 345 | 346 | killall postgres 347 | # wait for postgres to die 348 | while kill -0 "$CURRENT_POSTGRES_PID" &> /dev/null; do 349 | sleep 0.5 350 | done 351 | echo "postgres: down" 352 | } 353 | 354 | pushd () { 355 | command pushd "$@" > /dev/null 356 | } 357 | 358 | popd () { 359 | command popd "$@" > /dev/null 360 | } 361 | 362 | main $@ 363 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Stellar Quickstart Docker Image 2 | 3 | This project provides a simple way to incorporate stellar-core and horizon into your private infrastructure, provided that you use docker. 4 | 5 | This image provides a default, non-validating, ephemeral configuration that should work for most developers. By configuring a container using this image with a host-based volume (described below in the "Usage" section) an operator gains access to full configuration customization and persistence of data. 6 | 7 | The image uses the following software: 8 | 9 | - Postgresql 9.6 is used for storing both stellar-core and horizon data 10 | - [stellar-core](https://github.com/stellar/stellar-core) 11 | - [horizon](https://github.com/stellar/go/tree/master/services/horizon) 12 | - Supervisord is used from managing the processes of the services above 13 | 14 | ## Usage 15 | 16 | To use this project successfully, you should first decide a few things: 17 | 18 | First, decide whether you want your container to be part of the public, production Stellar network (referred to as the _pubnet_) or the test network (called testnet) that we recommend you use while developing software because you need not worry about losing money on the testnet. Additionally, we have added a standalone network (called standalone) which allows you to run your own private Stellar network. In standalone network mode, you can optionally pass `--protocol-version {version}` parameter to run a specific protocol version (defaults to latest version). You'll provide either `--pubnet`, `--testnet` or `--standalone` as a command line flag when starting the container to determine which network (and base configuration file) to use. 19 | 20 | Next, you must decide whether you will use a docker volume or not. When not using a volume, we say that the container is in _ephemeral mode_, that is, nothing will be persisted between runs of the container. _Persistent mode_ is the alternative, which should be used in the case that you need to either customize your configuration (such as to add a validation seed) or would like avoid a slow catchup to the Stellar network in the case of a crash or server restart. We recommend persistent mode for anything besides a development or test environment. 21 | 22 | Finally, you must decide what ports to expose. The software in these images listen on 4 ports, each of which you may or may not want to expose to the network your host system is connected to. A container that exposes no ports isn't very useful, so we recommend at a minimum you expose the horizon http port. See the "Ports" section below for a more nuanced discussion regarding the decision about what ports to expose. 23 | 24 | After deciding on the questions above, you can setup your container. Please refer to the appropriate section below based upon what mode you will run the container in. 25 | 26 | ### Background vs. Interactive containers 27 | 28 | Docker containers can be run interactively (using the `-it` flags) or in a detached, background state (using the `-d` flag). Many of the example commands below use the `-it` flags to aid in debugging but in many cases you will simply want to run a node in the background. It's recommended that you use the use [the tutorials at docker](https://docs.docker.com/engine/tutorials/usingdocker/) to familiarize yourself with using docker. 29 | 30 | ### Ephemeral mode 31 | 32 | Ephermeral mode is provided to support development and testing environments. Every time you start a container in ephemeral mode, the database starts empty and a default configuration file will be used for the appropriate network. 33 | 34 | Starting an ephemeral node is simple, just craft a `docker run` command to launch the appropriate image but *do not mount a volume*. To craft your docker command, you need the network name you intend to run against and the flags to expose the ports your want available (See the section named "Ports" below to learn about exposing ports). Thus, launching a testnet node while exposing horizon would be: 35 | 36 | ```shell 37 | $ docker run --rm -it -p "8000:8000" --name stellar stellar/quickstart --testnet 38 | ``` 39 | 40 | As part of launching, an ephemeral mode container will generate a random password for securing the postgresql service and will output it to standard out. You may use this password (provided you have exposed the postgresql port) to access the running postgresql database (See the section "Accessing Databases" below). 41 | 42 | 43 | ### Persistent mode 44 | 45 | In comparison to ephemeral mode, persistent mode is more complicated to operate, but also more powerful. Persistent mode uses a mounted host volume, a directory on the host machine that is exposed to the running docker container, to store all database data as well as the configuration files used for running services. This allows you to manage and modify these files from the host system. 46 | 47 | Starting a persistent mode container is the same as the ephemeral mode with one exception: 48 | 49 | ```shell 50 | $ docker run --rm -it -p "8000:8000" -v "/home/scott/stellar:/opt/stellar" --name stellar stellar/quickstart --testnet 51 | ``` 52 | 53 | The `-v` option in the example above tells docker to mount the host directory `/home/scott/stellar` into the container at the `/opt/stellar` path. You may customize the host directory to any location you like, simply make sure to use the same value every time you launch the container. Also note: an absolute directory path is required. The second portion of the volume mount (`/opt/stellar`) should never be changed. This special directory is checked by the container to see if it is mounted from the host system which is used to see if we should launch in ephemeral or persistent mode. 54 | 55 | Upon launching a persistent mode container for the first time, the launch script will notice that the mounted volume is empty. This will trigger an interactive initialization process to populate the initial configuration for the container. This interactive initialization adds some complications to the setup process because in most cases you won't want to run the container interactively during normal operation, but rather in the background. We recommend the following steps to setup a persistent mode node: 56 | 57 | 1. Run an interactive session of the container at first, ensuring that all services start and run correctly. 58 | 2. Shut down the interactive container (using Ctrl-C). 59 | 3. Start a new container using the same host directory in the background. 60 | 61 | 62 | ### Customizing configurations 63 | 64 | To customize the configurations that both stellar-core and horizon use, you must use persistent mode. The default configurations will be copied into the data directory upon launching a persistent mode container for the first time. Use the diagram below to learn about the various configuration files that can be customized. 65 | 66 | ``` 67 | /opt/stellar 68 | |-- core 69 | | `-- etc 70 | | `-- stellar-core.cfg # Stellar core config 71 | |-- horizon 72 | | `-- etc 73 | | `-- horizon.env # A shell script that exports horizon's config 74 | |-- postgresql 75 | | `-- etc 76 | | |-- postgresql.conf # Postgresql root configuration file 77 | | |-- pg_hba.conf # Postgresql client configuration file 78 | | `-- pg_ident.conf # Postgresql user mapping file 79 | `-- supervisor 80 | `-- etc 81 | | `-- supervisord.conf # Supervisord root configuration 82 | ``` 83 | 84 | It is recommended that you stop the container before editing any of these files, then restart the container after completing your customization. 85 | 86 | *NOTE:* Be wary of editing these files. It is possible to break the services started within this container with a bad edit. It's recommended that you learn about managing the operations of each of the services before customizing them, as you are taking responsibility for maintaining those services going forward. 87 | 88 | 89 | ## Regarding user accounts 90 | 91 | Managing UIDs between a docker container and a host volume can be complicated. At present, this image simply tries to create a UID that does not conflict with the host system by using a preset UID: 10011001. Currently there is no way to customize this value. All data produced in the host volume be owned by 10011001. If this UID value is inappropriate for your infrastructure we recommend you fork this project and do a find/replace operation to change UIDs. We may improve this story in the future if enough users request it. 92 | 93 | ## Ports 94 | 95 | | Port | Service | Description | 96 | |-------|--------------|----------------------| 97 | | 5432 | postgresql | database access port | 98 | | 8000 | horizon | main http port | 99 | | 11625 | stellar-core | peer node port | 100 | | 11626 | stellar-core | main http port | 101 | 102 | 103 | ### Security Considerations 104 | 105 | Exposing the network ports used by your running container comes with potential risks. While many attacks are preventable due to the nature of the stellar network, it is extremely important that you maintain protected access to the postgresql server that runs within a quickstart container. An attacker who gains write access to this DB will be able to corrupt your view of the stellar network, potentially inserting fake transactions, accounts, etc. 106 | 107 | It is safe to open the horizon http port. Horizon is designed to listen on an internet-facing interface and provides no privileged operations on the port. 108 | 109 | The HTTP port for stellar-core should only be exposed to a trusted network, as it provides no security itself. An attacker that can make requests to the port will be able to perform administrative commands such as forcing a catchup or changing the logging level and more, many of which could be used to disrupt operations or deny service. 110 | 111 | The peer port for stellar-core however can be exposed, and ideally would be routable from the internet. This would allow external peers to initiate connections to your node, improving connectivity of the overlay network. However, this is not required as your container will also establish outgoing connections to peers. 112 | 113 | ## Accessing and debugging a running container 114 | 115 | There will come a time when you want to inspect the running container, either to debug one of the services, to review logs, or perhaps some other administrative tasks. We do this by starting a new interactive shell inside the running container: 116 | 117 | ``` 118 | $ docker exec -it stellar /bin/bash 119 | ``` 120 | 121 | The command above assumes that you launched your container with the name `stellar`; Replace that name with whatever you chose if different. When run, it will open an interactive shell running as root within the container. 122 | 123 | ### Restarting services 124 | 125 | Services within the quickstart container are managed using [supervisord](http://supervisord.org/index.html) and we recommend you use supervisor's shell to interact with running services. To launch the supervisor shell, open an interactive shell to the container and then run `supervisorctl`. You should then see a command prompt that looks like: 126 | 127 | ```shell 128 | horizon RUNNING pid 143, uptime 0:01:12 129 | postgresql RUNNING pid 126, uptime 0:01:13 130 | stellar-core RUNNING pid 125, uptime 0:01:13 131 | supervisor> 132 | ``` 133 | 134 | From this prompt you can execute any of the supervisord commands: 135 | 136 | ```shell 137 | # restart horizon 138 | supervisor> restart horizon 139 | 140 | 141 | # stop stellar-core 142 | supervisor> stop stellar-core 143 | ``` 144 | 145 | You can learn more about what commands are available by using the `help` command. 146 | 147 | ### Viewing logs 148 | 149 | Logs can be found within the container at the path `/var/log/supervisor/`. A file is kept for both the stdout and stderr of the processes managed by supervisord. Additionally, you can use the `tail` command provided by supervisorctl. 150 | 151 | ### Accessing databases 152 | 153 | The point of this project is to make running stellar's software within your own infrastructure easier, so that your software can more easily integrate with the stellar network. In many cases, you can integrate with horizon's REST API, but often times you'll want direct access to the database either horizon or stellar-core provide. This allows you to craft your own custom sql queries against the stellar network data. 154 | 155 | This image manages two postgres databases: `core` for stellar-core's data and `horizon` for horizon's data. The username to use when connecting with your postgresql client or library is `stellar`. The password to use is dependent upon the mode your container is running in: Persistent mode uses a password supplied by you and ephemeral mode generates a password and prints it to the console upon container startup. 156 | 157 | 158 | ## Example launch commands 159 | 160 | Below is a list of various ways you might want to launch the quickstart container annotated to illustrate what options are enabled. It's also recommended that you should learn and get familiar with the docker command. 161 | 162 | *Launch an ephemeral pubnet node in the background:* 163 | ``` 164 | $ docker run -d -p "8000:8000" --name stellar stellar/quickstart --pubnet 165 | ``` 166 | 167 | *Launch an ephemeral testnet node in the foreground, exposing all ports:* 168 | ``` 169 | $ docker run --rm -it \ 170 | -p "8000:8000" \ 171 | -p "11626:11626" \ 172 | -p "11625:11625" \ 173 | --name stellar \ 174 | stellar/quickstart --testnet 175 | ``` 176 | 177 | *Setup a new persistent node using the host directory `/str`:* 178 | ``` 179 | $ docker run -it --rm \ 180 | -v "/str:/opt/stellar" \ 181 | --name stellar \ 182 | stellar/quickstart --pubnet 183 | ``` 184 | 185 | *Start a background persistent container for an already initialized host directory:* 186 | ``` 187 | $ docker run -d \ 188 | -v "/str:/opt/stellar" \ 189 | -p "8000:8000" \ 190 | --name stellar \ 191 | stellar/quickstart --pubnet 192 | ``` 193 | 194 | ## Troubleshooting 195 | 196 | Let us know what you're having trouble with! Open an issue or join us on our public slack channel. 197 | -------------------------------------------------------------------------------- /common/postgresql/etc/postgresql.conf: -------------------------------------------------------------------------------- 1 | # ----------------------------- 2 | # PostgreSQL configuration file 3 | # ----------------------------- 4 | # 5 | # This file consists of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # (The "=" is optional.) Whitespace may be used. Comments are introduced with 10 | # "#" anywhere on a line. The complete list of parameter names and allowed 11 | # values can be found in the PostgreSQL documentation. 12 | # 13 | # The commented-out settings shown in this file represent the default values. 14 | # Re-commenting a setting is NOT sufficient to revert it to the default value; 15 | # you need to reload the server. 16 | # 17 | # This file is read on server startup and when the server receives a SIGHUP 18 | # signal. If you edit the file on a running system, you have to SIGHUP the 19 | # server for the changes to take effect, or use "pg_ctl reload". Some 20 | # parameters, which are marked below, require a server shutdown and restart to 21 | # take effect. 22 | # 23 | # Any parameter can also be given as a command-line option to the server, e.g., 24 | # "postgres -c log_connections=on". Some parameters can be changed at run time 25 | # with the "SET" SQL command. 26 | # 27 | # Memory units: kB = kilobytes Time units: ms = milliseconds 28 | # MB = megabytes s = seconds 29 | # GB = gigabytes min = minutes 30 | # TB = terabytes h = hours 31 | # d = days 32 | 33 | 34 | #------------------------------------------------------------------------------ 35 | # FILE LOCATIONS 36 | #------------------------------------------------------------------------------ 37 | 38 | # The default values of these variables are driven from the -D command-line 39 | # option or PGDATA environment variable, represented here as ConfigDir. 40 | 41 | data_directory = '/opt/stellar/postgresql/data' 42 | hba_file = '/opt/stellar/postgresql/etc/pg_hba.conf' 43 | ident_file = '/opt/stellar/postgresql/etc/pg_ident.conf' 44 | 45 | #------------------------------------------------------------------------------ 46 | # CONNECTIONS AND AUTHENTICATION 47 | #------------------------------------------------------------------------------ 48 | 49 | # - Connection Settings - 50 | 51 | listen_addresses = '*' 52 | port = 5432 # (change requires restart) 53 | max_connections = 100 # (change requires restart) 54 | # Note: Increasing max_connections costs ~400 bytes of shared memory per 55 | # connection slot, plus lock space (see max_locks_per_transaction). 56 | #superuser_reserved_connections = 3 # (change requires restart) 57 | #unix_socket_directories = '/opt/stellar/postgresql/run' 58 | #unix_socket_group = '' # (change requires restart) 59 | #unix_socket_permissions = 0777 # begin with 0 to use octal notation 60 | # (change requires restart) 61 | #bonjour = off # advertise server via Bonjour 62 | # (change requires restart) 63 | #bonjour_name = '' # defaults to the computer name 64 | # (change requires restart) 65 | 66 | # - Security and Authentication - 67 | 68 | #authentication_timeout = 1min # 1s-600s 69 | ssl = true # (change requires restart) 70 | #ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers 71 | # (change requires restart) 72 | #ssl_prefer_server_ciphers = on # (change requires restart) 73 | #ssl_ecdh_curve = 'prime256v1' # (change requires restart) 74 | #ssl_renegotiation_limit = 0 # amount of data between renegotiations 75 | ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' # (change requires restart) 76 | ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' # (change requires restart) 77 | #ssl_ca_file = '' # (change requires restart) 78 | #ssl_crl_file = '' # (change requires restart) 79 | #password_encryption = on 80 | #db_user_namespace = off 81 | 82 | # GSSAPI using Kerberos 83 | #krb_server_keyfile = '' 84 | #krb_caseins_users = off 85 | 86 | # - TCP Keepalives - 87 | # see "man 7 tcp" for details 88 | 89 | #tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; 90 | # 0 selects the system default 91 | #tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; 92 | # 0 selects the system default 93 | #tcp_keepalives_count = 0 # TCP_KEEPCNT; 94 | # 0 selects the system default 95 | 96 | 97 | #------------------------------------------------------------------------------ 98 | # RESOURCE USAGE (except WAL) 99 | #------------------------------------------------------------------------------ 100 | 101 | # - Memory - 102 | 103 | shared_buffers = 128MB # min 128kB 104 | # (change requires restart) 105 | #huge_pages = try # on, off, or try 106 | # (change requires restart) 107 | #temp_buffers = 8MB # min 800kB 108 | #max_prepared_transactions = 0 # zero disables the feature 109 | # (change requires restart) 110 | # Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory 111 | # per transaction slot, plus lock space (see max_locks_per_transaction). 112 | # It is not advisable to set max_prepared_transactions nonzero unless you 113 | # actively intend to use prepared transactions. 114 | #work_mem = 4MB # min 64kB 115 | #maintenance_work_mem = 64MB # min 1MB 116 | #autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem 117 | #max_stack_depth = 2MB # min 100kB 118 | dynamic_shared_memory_type = posix # the default is the first option 119 | # supported by the operating system: 120 | # posix 121 | # sysv 122 | # windows 123 | # mmap 124 | # use none to disable dynamic shared memory 125 | 126 | # - Disk - 127 | 128 | #temp_file_limit = -1 # limits per-session temp file space 129 | # in kB, or -1 for no limit 130 | 131 | # - Kernel Resource Usage - 132 | 133 | #max_files_per_process = 1000 # min 25 134 | # (change requires restart) 135 | #shared_preload_libraries = '' # (change requires restart) 136 | 137 | # - Cost-Based Vacuum Delay - 138 | 139 | #vacuum_cost_delay = 0 # 0-100 milliseconds 140 | #vacuum_cost_page_hit = 1 # 0-10000 credits 141 | #vacuum_cost_page_miss = 10 # 0-10000 credits 142 | #vacuum_cost_page_dirty = 20 # 0-10000 credits 143 | #vacuum_cost_limit = 200 # 1-10000 credits 144 | 145 | # - Background Writer - 146 | 147 | #bgwriter_delay = 200ms # 10-10000ms between rounds 148 | #bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round 149 | #bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round 150 | 151 | # - Asynchronous Behavior - 152 | 153 | #effective_io_concurrency = 1 # 1-1000; 0 disables prefetching 154 | #max_worker_processes = 8 155 | 156 | 157 | #------------------------------------------------------------------------------ 158 | # WRITE AHEAD LOG 159 | #------------------------------------------------------------------------------ 160 | 161 | # - Settings - 162 | 163 | #wal_level = minimal # minimal, archive, hot_standby, or logical 164 | # (change requires restart) 165 | #fsync = on # turns forced synchronization on or off 166 | #synchronous_commit = on # synchronization level; 167 | # off, local, remote_write, or on 168 | #wal_sync_method = fsync # the default is the first option 169 | # supported by the operating system: 170 | # open_datasync 171 | # fdatasync (default on Linux) 172 | # fsync 173 | # fsync_writethrough 174 | # open_sync 175 | #full_page_writes = on # recover from partial page writes 176 | #wal_log_hints = off # also do full page writes of non-critical updates 177 | # (change requires restart) 178 | #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers 179 | # (change requires restart) 180 | #wal_writer_delay = 200ms # 1-10000 milliseconds 181 | 182 | #commit_delay = 0 # range 0-100000, in microseconds 183 | #commit_siblings = 5 # range 1-1000 184 | 185 | # - Checkpoints - 186 | 187 | #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each 188 | #checkpoint_timeout = 5min # range 30s-1h 189 | #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 190 | #checkpoint_warning = 30s # 0 disables 191 | 192 | # - Archiving - 193 | 194 | #archive_mode = off # allows archiving to be done 195 | # (change requires restart) 196 | #archive_command = '' # command to use to archive a logfile segment 197 | # placeholders: %p = path of file to archive 198 | # %f = file name only 199 | # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' 200 | #archive_timeout = 0 # force a logfile segment switch after this 201 | # number of seconds; 0 disables 202 | 203 | 204 | #------------------------------------------------------------------------------ 205 | # REPLICATION 206 | #------------------------------------------------------------------------------ 207 | 208 | # - Sending Server(s) - 209 | 210 | # Set these on the master and on any standby that will send replication data. 211 | 212 | #max_wal_senders = 0 # max number of walsender processes 213 | # (change requires restart) 214 | #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables 215 | #wal_sender_timeout = 60s # in milliseconds; 0 disables 216 | 217 | #max_replication_slots = 0 # max number of replication slots 218 | # (change requires restart) 219 | 220 | # - Master Server - 221 | 222 | # These settings are ignored on a standby server. 223 | 224 | #synchronous_standby_names = '' # standby servers that provide sync rep 225 | # comma-separated list of application_name 226 | # from standby(s); '*' = all 227 | #vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed 228 | 229 | # - Standby Servers - 230 | 231 | # These settings are ignored on a master server. 232 | 233 | #hot_standby = off # "on" allows queries during recovery 234 | # (change requires restart) 235 | #max_standby_archive_delay = 30s # max delay before canceling queries 236 | # when reading WAL from archive; 237 | # -1 allows indefinite delay 238 | #max_standby_streaming_delay = 30s # max delay before canceling queries 239 | # when reading streaming WAL; 240 | # -1 allows indefinite delay 241 | #wal_receiver_status_interval = 10s # send replies at least this often 242 | # 0 disables 243 | #hot_standby_feedback = off # send info from standby to prevent 244 | # query conflicts 245 | #wal_receiver_timeout = 60s # time that receiver waits for 246 | # communication from master 247 | # in milliseconds; 0 disables 248 | 249 | 250 | #------------------------------------------------------------------------------ 251 | # QUERY TUNING 252 | #------------------------------------------------------------------------------ 253 | 254 | # - Planner Method Configuration - 255 | 256 | #enable_bitmapscan = on 257 | #enable_hashagg = on 258 | #enable_hashjoin = on 259 | #enable_indexscan = on 260 | #enable_indexonlyscan = on 261 | #enable_material = on 262 | #enable_mergejoin = on 263 | #enable_nestloop = on 264 | #enable_seqscan = on 265 | #enable_sort = on 266 | #enable_tidscan = on 267 | 268 | # - Planner Cost Constants - 269 | 270 | #seq_page_cost = 1.0 # measured on an arbitrary scale 271 | #random_page_cost = 4.0 # same scale as above 272 | #cpu_tuple_cost = 0.01 # same scale as above 273 | #cpu_index_tuple_cost = 0.005 # same scale as above 274 | #cpu_operator_cost = 0.0025 # same scale as above 275 | #effective_cache_size = 4GB 276 | 277 | # - Genetic Query Optimizer - 278 | 279 | #geqo = on 280 | #geqo_threshold = 12 281 | #geqo_effort = 5 # range 1-10 282 | #geqo_pool_size = 0 # selects default based on effort 283 | #geqo_generations = 0 # selects default based on effort 284 | #geqo_selection_bias = 2.0 # range 1.5-2.0 285 | #geqo_seed = 0.0 # range 0.0-1.0 286 | 287 | # - Other Planner Options - 288 | 289 | #default_statistics_target = 100 # range 1-10000 290 | #constraint_exclusion = partition # on, off, or partition 291 | #cursor_tuple_fraction = 0.1 # range 0.0-1.0 292 | #from_collapse_limit = 8 293 | #join_collapse_limit = 8 # 1 disables collapsing of explicit 294 | # JOIN clauses 295 | 296 | 297 | #------------------------------------------------------------------------------ 298 | # ERROR REPORTING AND LOGGING 299 | #------------------------------------------------------------------------------ 300 | 301 | # - Where to Log - 302 | 303 | #log_destination = 'stderr' # Valid values are combinations of 304 | # stderr, csvlog, syslog, and eventlog, 305 | # depending on platform. csvlog 306 | # requires logging_collector to be on. 307 | 308 | # This is used when logging to stderr: 309 | #logging_collector = off # Enable capturing of stderr and csvlog 310 | # into log files. Required to be on for 311 | # csvlogs. 312 | # (change requires restart) 313 | 314 | # These are only used if logging_collector is on: 315 | #log_directory = 'pg_log' # directory where log files are written, 316 | # can be absolute or relative to PGDATA 317 | #log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, 318 | # can include strftime() escapes 319 | #log_file_mode = 0600 # creation mode for log files, 320 | # begin with 0 to use octal notation 321 | #log_truncate_on_rotation = off # If on, an existing log file with the 322 | # same name as the new log file will be 323 | # truncated rather than appended to. 324 | # But such truncation only occurs on 325 | # time-driven rotation, not on restarts 326 | # or size-driven rotation. Default is 327 | # off, meaning append to existing files 328 | # in all cases. 329 | #log_rotation_age = 1d # Automatic rotation of logfiles will 330 | # happen after that time. 0 disables. 331 | #log_rotation_size = 10MB # Automatic rotation of logfiles will 332 | # happen after that much log output. 333 | # 0 disables. 334 | 335 | # These are relevant when logging to syslog: 336 | #syslog_facility = 'LOCAL0' 337 | #syslog_ident = 'postgres' 338 | 339 | # This is only relevant when logging to eventlog (win32): 340 | #event_source = 'PostgreSQL' 341 | 342 | # - When to Log - 343 | 344 | #client_min_messages = notice # values in order of decreasing detail: 345 | # debug5 346 | # debug4 347 | # debug3 348 | # debug2 349 | # debug1 350 | # log 351 | # notice 352 | # warning 353 | # error 354 | 355 | #log_min_messages = warning # values in order of decreasing detail: 356 | # debug5 357 | # debug4 358 | # debug3 359 | # debug2 360 | # debug1 361 | # info 362 | # notice 363 | # warning 364 | # error 365 | # log 366 | # fatal 367 | # panic 368 | 369 | #log_min_error_statement = error # values in order of decreasing detail: 370 | # debug5 371 | # debug4 372 | # debug3 373 | # debug2 374 | # debug1 375 | # info 376 | # notice 377 | # warning 378 | # error 379 | # log 380 | # fatal 381 | # panic (effectively off) 382 | 383 | #log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements 384 | # and their durations, > 0 logs only 385 | # statements running at least this number 386 | # of milliseconds 387 | 388 | 389 | # - What to Log - 390 | 391 | #debug_print_parse = off 392 | #debug_print_rewritten = off 393 | #debug_print_plan = off 394 | #debug_pretty_print = on 395 | #log_checkpoints = off 396 | #log_connections = off 397 | #log_disconnections = off 398 | #log_duration = off 399 | #log_error_verbosity = default # terse, default, or verbose messages 400 | #log_hostname = off 401 | log_line_prefix = '%t [%p-%l] %q%u@%d ' # special values: 402 | # %a = application name 403 | # %u = user name 404 | # %d = database name 405 | # %r = remote host and port 406 | # %h = remote host 407 | # %p = process ID 408 | # %t = timestamp without milliseconds 409 | # %m = timestamp with milliseconds 410 | # %i = command tag 411 | # %e = SQL state 412 | # %c = session ID 413 | # %l = session line number 414 | # %s = session start timestamp 415 | # %v = virtual transaction ID 416 | # %x = transaction ID (0 if none) 417 | # %q = stop here in non-session 418 | # processes 419 | # %% = '%' 420 | # e.g. '<%u%%%d> ' 421 | #log_lock_waits = off # log lock waits >= deadlock_timeout 422 | #log_statement = 'none' # none, ddl, mod, all 423 | #log_temp_files = -1 # log temporary files equal or larger 424 | # than the specified size in kilobytes; 425 | # -1 disables, 0 logs all temp files 426 | log_timezone = 'UTC' 427 | 428 | 429 | #------------------------------------------------------------------------------ 430 | # RUNTIME STATISTICS 431 | #------------------------------------------------------------------------------ 432 | 433 | # - Query/Index Statistics Collector - 434 | 435 | #track_activities = on 436 | #track_counts = on 437 | #track_io_timing = off 438 | #track_functions = none # none, pl, all 439 | #track_activity_query_size = 1024 # (change requires restart) 440 | #update_process_title = on 441 | # stats_temp_directory = '' 442 | 443 | 444 | # - Statistics Monitoring - 445 | 446 | #log_parser_stats = off 447 | #log_planner_stats = off 448 | #log_executor_stats = off 449 | #log_statement_stats = off 450 | 451 | 452 | #------------------------------------------------------------------------------ 453 | # AUTOVACUUM PARAMETERS 454 | #------------------------------------------------------------------------------ 455 | 456 | #autovacuum = on # Enable autovacuum subprocess? 'on' 457 | # requires track_counts to also be on. 458 | #log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and 459 | # their durations, > 0 logs only 460 | # actions running at least this number 461 | # of milliseconds. 462 | #autovacuum_max_workers = 3 # max number of autovacuum subprocesses 463 | # (change requires restart) 464 | #autovacuum_naptime = 1min # time between autovacuum runs 465 | #autovacuum_vacuum_threshold = 50 # min number of row updates before 466 | # vacuum 467 | #autovacuum_analyze_threshold = 50 # min number of row updates before 468 | # analyze 469 | #autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum 470 | #autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze 471 | #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum 472 | # (change requires restart) 473 | #autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age 474 | # before forced vacuum 475 | # (change requires restart) 476 | #autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for 477 | # autovacuum, in milliseconds; 478 | # -1 means use vacuum_cost_delay 479 | #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for 480 | # autovacuum, -1 means use 481 | # vacuum_cost_limit 482 | 483 | 484 | #------------------------------------------------------------------------------ 485 | # CLIENT CONNECTION DEFAULTS 486 | #------------------------------------------------------------------------------ 487 | 488 | # - Statement Behavior - 489 | 490 | #search_path = '"$user",public' # schema names 491 | #default_tablespace = '' # a tablespace name, '' uses the default 492 | #temp_tablespaces = '' # a list of tablespace names, '' uses 493 | # only default tablespace 494 | #check_function_bodies = on 495 | #default_transaction_isolation = 'read committed' 496 | #default_transaction_read_only = off 497 | #default_transaction_deferrable = off 498 | #session_replication_role = 'origin' 499 | #statement_timeout = 0 # in milliseconds, 0 is disabled 500 | #lock_timeout = 0 # in milliseconds, 0 is disabled 501 | #vacuum_freeze_min_age = 50000000 502 | #vacuum_freeze_table_age = 150000000 503 | #vacuum_multixact_freeze_min_age = 5000000 504 | #vacuum_multixact_freeze_table_age = 150000000 505 | #bytea_output = 'hex' # hex, escape 506 | #xmlbinary = 'base64' 507 | #xmloption = 'content' 508 | #gin_fuzzy_search_limit = 0 509 | 510 | # - Locale and Formatting - 511 | 512 | datestyle = 'iso, mdy' 513 | #intervalstyle = 'postgres' 514 | timezone = 'UTC' 515 | #timezone_abbreviations = 'Default' # Select the set of available time zone 516 | # abbreviations. Currently, there are 517 | # Default 518 | # Australia (historical usage) 519 | # India 520 | # You can create your own file in 521 | # share/timezonesets/. 522 | #extra_float_digits = 0 # min -15, max 3 523 | #client_encoding = sql_ascii # actually, defaults to database 524 | # encoding 525 | 526 | # These settings are initialized by initdb, but they can be changed. 527 | lc_messages = 'C' # locale for system error message 528 | # strings 529 | lc_monetary = 'C' # locale for monetary formatting 530 | lc_numeric = 'C' # locale for number formatting 531 | lc_time = 'C' # locale for time formatting 532 | 533 | # default configuration for text search 534 | default_text_search_config = 'pg_catalog.english' 535 | 536 | # - Other Defaults - 537 | 538 | #dynamic_library_path = '$libdir' 539 | #local_preload_libraries = '' 540 | #session_preload_libraries = '' 541 | 542 | 543 | #------------------------------------------------------------------------------ 544 | # LOCK MANAGEMENT 545 | #------------------------------------------------------------------------------ 546 | 547 | #deadlock_timeout = 1s 548 | #max_locks_per_transaction = 64 # min 10 549 | # (change requires restart) 550 | # Note: Each lock table slot uses ~270 bytes of shared memory, and there are 551 | # max_locks_per_transaction * (max_connections + max_prepared_transactions) 552 | # lock table slots. 553 | #max_pred_locks_per_transaction = 64 # min 10 554 | # (change requires restart) 555 | 556 | 557 | #------------------------------------------------------------------------------ 558 | # VERSION/PLATFORM COMPATIBILITY 559 | #------------------------------------------------------------------------------ 560 | 561 | # - Previous PostgreSQL Versions - 562 | 563 | #array_nulls = on 564 | #backslash_quote = safe_encoding # on, off, or safe_encoding 565 | #default_with_oids = off 566 | #escape_string_warning = on 567 | #lo_compat_privileges = off 568 | #quote_all_identifiers = off 569 | #sql_inheritance = on 570 | #standard_conforming_strings = on 571 | #synchronize_seqscans = on 572 | 573 | # - Other Platforms and Clients - 574 | 575 | #transform_null_equals = off 576 | 577 | 578 | #------------------------------------------------------------------------------ 579 | # ERROR HANDLING 580 | #------------------------------------------------------------------------------ 581 | 582 | #exit_on_error = off # terminate session on any error? 583 | #restart_after_crash = on # reinitialize after backend crash? 584 | 585 | 586 | #------------------------------------------------------------------------------ 587 | # CONFIG FILE INCLUDES 588 | #------------------------------------------------------------------------------ 589 | 590 | # These options allow settings to be loaded from files other than the 591 | # default postgresql.conf. 592 | 593 | #include_dir = 'conf.d' # include files ending in '.conf' from 594 | # directory 'conf.d' 595 | #include_if_exists = 'exists.conf' # include file only if it exists 596 | #include = 'special.conf' # include file 597 | 598 | 599 | #------------------------------------------------------------------------------ 600 | # CUSTOMIZED OPTIONS 601 | #------------------------------------------------------------------------------ 602 | 603 | # Add settings for extensions here 604 | --------------------------------------------------------------------------------