first commit
1084 files changed, +2040 -0
| @@ -0,0 +1 @@ | ||
| 1 | +16 |
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
| @@ -0,0 +1 @@ | ||
| 1 | +16 |
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
| @@ -0,0 +1 @@ | ||
| 1 | +16 |
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
| @@ -0,0 +1 @@ | ||
| 1 | +16 |
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
No content changes (mode or rename only).
No content changes (mode or rename only).
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
| @@ -0,0 +1,128 @@ | ||
| 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 | +# ---------------------- | |
| 9 | +# Authentication Records | |
| 10 | +# ---------------------- | |
| 11 | +# | |
| 12 | +# This file controls: which hosts are allowed to connect, how clients | |
| 13 | +# are authenticated, which PostgreSQL user names they can use, which | |
| 14 | +# databases they can access. Records take one of these forms: | |
| 15 | +# | |
| 16 | +# local DATABASE USER METHOD [OPTIONS] | |
| 17 | +# host DATABASE USER ADDRESS METHOD [OPTIONS] | |
| 18 | +# hostssl DATABASE USER ADDRESS METHOD [OPTIONS] | |
| 19 | +# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] | |
| 20 | +# hostgssenc DATABASE USER ADDRESS METHOD [OPTIONS] | |
| 21 | +# hostnogssenc DATABASE USER ADDRESS METHOD [OPTIONS] | |
| 22 | +# | |
| 23 | +# (The uppercase items must be replaced by actual values.) | |
| 24 | +# | |
| 25 | +# The first field is the connection type: | |
| 26 | +# - "local" is a Unix-domain socket | |
| 27 | +# - "host" is a TCP/IP socket (encrypted or not) | |
| 28 | +# - "hostssl" is a TCP/IP socket that is SSL-encrypted | |
| 29 | +# - "hostnossl" is a TCP/IP socket that is not SSL-encrypted | |
| 30 | +# - "hostgssenc" is a TCP/IP socket that is GSSAPI-encrypted | |
| 31 | +# - "hostnogssenc" is a TCP/IP socket that is not GSSAPI-encrypted | |
| 32 | +# | |
| 33 | +# DATABASE can be "all", "sameuser", "samerole", "replication", a | |
| 34 | +# database name, a regular expression (if it starts with a slash (/)) | |
| 35 | +# or a comma-separated list thereof. The "all" keyword does not match | |
| 36 | +# "replication". Access to replication must be enabled in a separate | |
| 37 | +# record (see example below). | |
| 38 | +# | |
| 39 | +# USER can be "all", a user name, a group name prefixed with "+", a | |
| 40 | +# regular expression (if it starts with a slash (/)) or a comma-separated | |
| 41 | +# list thereof. In both the DATABASE and USER fields you can also write | |
| 42 | +# a file name prefixed with "@" to include names from a separate file. | |
| 43 | +# | |
| 44 | +# ADDRESS specifies the set of hosts the record matches. It can be a | |
| 45 | +# host name, or it is made up of an IP address and a CIDR mask that is | |
| 46 | +# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that | |
| 47 | +# specifies the number of significant bits in the mask. A host name | |
| 48 | +# that starts with a dot (.) matches a suffix of the actual host name. | |
| 49 | +# Alternatively, you can write an IP address and netmask in separate | |
| 50 | +# columns to specify the set of hosts. Instead of a CIDR-address, you | |
| 51 | +# can write "samehost" to match any of the server's own IP addresses, | |
| 52 | +# or "samenet" to match any address in any subnet that the server is | |
| 53 | +# directly connected to. | |
| 54 | +# | |
| 55 | +# METHOD can be "trust", "reject", "md5", "password", "scram-sha-256", | |
| 56 | +# "gss", "sspi", "ident", "peer", "pam", "ldap", "radius" or "cert". | |
| 57 | +# Note that "password" sends passwords in clear text; "md5" or | |
| 58 | +# "scram-sha-256" are preferred since they send encrypted passwords. | |
| 59 | +# | |
| 60 | +# OPTIONS are a set of options for the authentication in the format | |
| 61 | +# NAME=VALUE. The available options depend on the different | |
| 62 | +# authentication methods -- refer to the "Client Authentication" | |
| 63 | +# section in the documentation for a list of which options are | |
| 64 | +# available for which authentication methods. | |
| 65 | +# | |
| 66 | +# Database and user names containing spaces, commas, quotes and other | |
| 67 | +# special characters must be quoted. Quoting one of the keywords | |
| 68 | +# "all", "sameuser", "samerole" or "replication" makes the name lose | |
| 69 | +# its special character, and just match a database or username with | |
| 70 | +# that name. | |
| 71 | +# | |
| 72 | +# --------------- | |
| 73 | +# Include Records | |
| 74 | +# --------------- | |
| 75 | +# | |
| 76 | +# This file allows the inclusion of external files or directories holding | |
| 77 | +# more records, using the following keywords: | |
| 78 | +# | |
| 79 | +# include FILE | |
| 80 | +# include_if_exists FILE | |
| 81 | +# include_dir DIRECTORY | |
| 82 | +# | |
| 83 | +# FILE is the file name to include, and DIR is the directory name containing | |
| 84 | +# the file(s) to include. Any file in a directory will be loaded if suffixed | |
| 85 | +# with ".conf". The files of a directory are ordered by name. | |
| 86 | +# include_if_exists ignores missing files. FILE and DIRECTORY can be | |
| 87 | +# specified as a relative or an absolute path, and can be double-quoted if | |
| 88 | +# they contain spaces. | |
| 89 | +# | |
| 90 | +# ------------- | |
| 91 | +# Miscellaneous | |
| 92 | +# ------------- | |
| 93 | +# | |
| 94 | +# This file is read on server startup and when the server receives a | |
| 95 | +# SIGHUP signal. If you edit the file on a running system, you have to | |
| 96 | +# SIGHUP the server for the changes to take effect, run "pg_ctl reload", | |
| 97 | +# or execute "SELECT pg_reload_conf()". | |
| 98 | +# | |
| 99 | +# ---------------------------------- | |
| 100 | +# Put your actual configuration here | |
| 101 | +# ---------------------------------- | |
| 102 | +# | |
| 103 | +# If you want to allow non-local connections, you need to add more | |
| 104 | +# "host" records. In that case you will also need to make PostgreSQL | |
| 105 | +# listen on a non-local interface via the listen_addresses | |
| 106 | +# configuration parameter, or via the -i or -h command line switches. | |
| 107 | + | |
| 108 | +# CAUTION: Configuring the system for local "trust" authentication | |
| 109 | +# allows any local user to connect as any PostgreSQL user, including | |
| 110 | +# the database superuser. If you do not trust all your local users, | |
| 111 | +# use another authentication method. | |
| 112 | + | |
| 113 | + | |
| 114 | +# TYPE DATABASE USER ADDRESS METHOD | |
| 115 | + | |
| 116 | +# "local" is for Unix domain socket connections only | |
| 117 | +local all all trust | |
| 118 | +# IPv4 local connections: | |
| 119 | +host all all 127.0.0.1/32 trust | |
| 120 | +# IPv6 local connections: | |
| 121 | +host all all ::1/128 trust | |
| 122 | +# Allow replication connections from localhost, by a user with the | |
| 123 | +# replication privilege. | |
| 124 | +local replication all trust | |
| 125 | +host replication all 127.0.0.1/32 trust | |
| 126 | +host replication all ::1/128 trust | |
| 127 | + | |
| 128 | +host all all all scram-sha-256 |
| @@ -0,0 +1,72 @@ | ||
| 1 | +# PostgreSQL User Name Maps | |
| 2 | +# ========================= | |
| 3 | +# | |
| 4 | +# --------------- | |
| 5 | +# Mapping Records | |
| 6 | +# --------------- | |
| 7 | +# | |
| 8 | +# Refer to the PostgreSQL documentation, chapter "Client | |
| 9 | +# Authentication" for a complete description. A short synopsis | |
| 10 | +# follows. | |
| 11 | +# | |
| 12 | +# This file controls PostgreSQL user name mapping. It maps external | |
| 13 | +# user names to their corresponding PostgreSQL user names. Records | |
| 14 | +# are of the form: | |
| 15 | +# | |
| 16 | +# MAPNAME SYSTEM-USERNAME PG-USERNAME | |
| 17 | +# | |
| 18 | +# (The uppercase quantities must be replaced by actual values.) | |
| 19 | +# | |
| 20 | +# MAPNAME is the (otherwise freely chosen) map name that was used in | |
| 21 | +# pg_hba.conf. SYSTEM-USERNAME is the detected user name of the | |
| 22 | +# client. PG-USERNAME is the requested PostgreSQL user name. The | |
| 23 | +# existence of a record specifies that SYSTEM-USERNAME may connect as | |
| 24 | +# PG-USERNAME. | |
| 25 | +# | |
| 26 | +# If SYSTEM-USERNAME starts with a slash (/), it will be treated as a | |
| 27 | +# regular expression. Optionally this can contain a capture (a | |
| 28 | +# parenthesized subexpression). The substring matching the capture | |
| 29 | +# will be substituted for \1 (backslash-one) if present in | |
| 30 | +# PG-USERNAME. | |
| 31 | +# | |
| 32 | +# PG-USERNAME can be "all", a user name, a group name prefixed with "+", or | |
| 33 | +# a regular expression (if it starts with a slash (/)). If it is a regular | |
| 34 | +# expression, the substring matching with \1 has no effect. | |
| 35 | +# | |
| 36 | +# Multiple maps may be specified in this file and used by pg_hba.conf. | |
| 37 | +# | |
| 38 | +# No map names are defined in the default configuration. If all | |
| 39 | +# system user names and PostgreSQL user names are the same, you don't | |
| 40 | +# need anything in this file. | |
| 41 | +# | |
| 42 | +# --------------- | |
| 43 | +# Include Records | |
| 44 | +# --------------- | |
| 45 | +# | |
| 46 | +# This file allows the inclusion of external files or directories holding | |
| 47 | +# more records, using the following keywords: | |
| 48 | +# | |
| 49 | +# include FILE | |
| 50 | +# include_if_exists FILE | |
| 51 | +# include_dir DIRECTORY | |
| 52 | +# | |
| 53 | +# FILE is the file name to include, and DIR is the directory name containing | |
| 54 | +# the file(s) to include. Any file in a directory will be loaded if suffixed | |
| 55 | +# with ".conf". The files of a directory are ordered by name. | |
| 56 | +# include_if_exists ignores missing files. FILE and DIRECTORY can be | |
| 57 | +# specified as a relative or an absolute path, and can be double-quoted if | |
| 58 | +# they contain spaces. | |
| 59 | +# | |
| 60 | +# ------------------------------- | |
| 61 | +# Miscellaneous | |
| 62 | +# ------------------------------- | |
| 63 | +# | |
| 64 | +# This file is read on server startup and when the postmaster receives | |
| 65 | +# a SIGHUP signal. If you edit the file on a running system, you have | |
| 66 | +# to SIGHUP the postmaster for the changes to take effect. You can | |
| 67 | +# use "pg_ctl reload" to do that. | |
| 68 | + | |
| 69 | +# Put your actual configuration here | |
| 70 | +# ---------------------------------- | |
| 71 | + | |
| 72 | +# MAPNAME SYSTEM-USERNAME PG-USERNAME |
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
Binary file changed.
| @@ -0,0 +1,2 @@ | ||
| 1 | +# Do not edit this file manually! | |
| 2 | +# It will be overwritten by the ALTER SYSTEM command. |
| @@ -0,0 +1,820 @@ | ||
| 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, run "pg_ctl reload", or execute | |
| 20 | +# "SELECT pg_reload_conf()". Some parameters, which are marked below, | |
| 21 | +# require a server shutdown and restart to 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: B = bytes Time units: us = microseconds | |
| 28 | +# kB = kilobytes ms = milliseconds | |
| 29 | +# MB = megabytes s = seconds | |
| 30 | +# GB = gigabytes min = minutes | |
| 31 | +# TB = terabytes h = hours | |
| 32 | +# d = days | |
| 33 | + | |
| 34 | + | |
| 35 | +#------------------------------------------------------------------------------ | |
| 36 | +# FILE LOCATIONS | |
| 37 | +#------------------------------------------------------------------------------ | |
| 38 | + | |
| 39 | +# The default values of these variables are driven from the -D command-line | |
| 40 | +# option or PGDATA environment variable, represented here as ConfigDir. | |
| 41 | + | |
| 42 | +#data_directory = 'ConfigDir' # use data in another directory | |
| 43 | + # (change requires restart) | |
| 44 | +#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file | |
| 45 | + # (change requires restart) | |
| 46 | +#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file | |
| 47 | + # (change requires restart) | |
| 48 | + | |
| 49 | +# If external_pid_file is not explicitly set, no extra PID file is written. | |
| 50 | +#external_pid_file = '' # write an extra PID file | |
| 51 | + # (change requires restart) | |
| 52 | + | |
| 53 | + | |
| 54 | +#------------------------------------------------------------------------------ | |
| 55 | +# CONNECTIONS AND AUTHENTICATION | |
| 56 | +#------------------------------------------------------------------------------ | |
| 57 | + | |
| 58 | +# - Connection Settings - | |
| 59 | + | |
| 60 | +listen_addresses = '*' | |
| 61 | + # comma-separated list of addresses; | |
| 62 | + # defaults to 'localhost'; use '*' for all | |
| 63 | + # (change requires restart) | |
| 64 | +#port = 5432 # (change requires restart) | |
| 65 | +max_connections = 100 # (change requires restart) | |
| 66 | +#reserved_connections = 0 # (change requires restart) | |
| 67 | +#superuser_reserved_connections = 3 # (change requires restart) | |
| 68 | +#unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories | |
| 69 | + # (change requires restart) | |
| 70 | +#unix_socket_group = '' # (change requires restart) | |
| 71 | +#unix_socket_permissions = 0777 # begin with 0 to use octal notation | |
| 72 | + # (change requires restart) | |
| 73 | +#bonjour = off # advertise server via Bonjour | |
| 74 | + # (change requires restart) | |
| 75 | +#bonjour_name = '' # defaults to the computer name | |
| 76 | + # (change requires restart) | |
| 77 | + | |
| 78 | +# - TCP settings - | |
| 79 | +# see "man tcp" for details | |
| 80 | + | |
| 81 | +#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; | |
| 82 | + # 0 selects the system default | |
| 83 | +#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; | |
| 84 | + # 0 selects the system default | |
| 85 | +#tcp_keepalives_count = 0 # TCP_KEEPCNT; | |
| 86 | + # 0 selects the system default | |
| 87 | +#tcp_user_timeout = 0 # TCP_USER_TIMEOUT, in milliseconds; | |
| 88 | + # 0 selects the system default | |
| 89 | + | |
| 90 | +#client_connection_check_interval = 0 # time between checks for client | |
| 91 | + # disconnection while running queries; | |
| 92 | + # 0 for never | |
| 93 | + | |
| 94 | +# - Authentication - | |
| 95 | + | |
| 96 | +#authentication_timeout = 1min # 1s-600s | |
| 97 | +#password_encryption = scram-sha-256 # scram-sha-256 or md5 | |
| 98 | +#scram_iterations = 4096 | |
| 99 | +#db_user_namespace = off | |
| 100 | + | |
| 101 | +# GSSAPI using Kerberos | |
| 102 | +#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab' | |
| 103 | +#krb_caseins_users = off | |
| 104 | +#gss_accept_delegation = off | |
| 105 | + | |
| 106 | +# - SSL - | |
| 107 | + | |
| 108 | +#ssl = off | |
| 109 | +#ssl_ca_file = '' | |
| 110 | +#ssl_cert_file = 'server.crt' | |
| 111 | +#ssl_crl_file = '' | |
| 112 | +#ssl_crl_dir = '' | |
| 113 | +#ssl_key_file = 'server.key' | |
| 114 | +#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers | |
| 115 | +#ssl_prefer_server_ciphers = on | |
| 116 | +#ssl_ecdh_curve = 'prime256v1' | |
| 117 | +#ssl_min_protocol_version = 'TLSv1.2' | |
| 118 | +#ssl_max_protocol_version = '' | |
| 119 | +#ssl_dh_params_file = '' | |
| 120 | +#ssl_passphrase_command = '' | |
| 121 | +#ssl_passphrase_command_supports_reload = off | |
| 122 | + | |
| 123 | + | |
| 124 | +#------------------------------------------------------------------------------ | |
| 125 | +# RESOURCE USAGE (except WAL) | |
| 126 | +#------------------------------------------------------------------------------ | |
| 127 | + | |
| 128 | +# - Memory - | |
| 129 | + | |
| 130 | +shared_buffers = 128MB # min 128kB | |
| 131 | + # (change requires restart) | |
| 132 | +#huge_pages = try # on, off, or try | |
| 133 | + # (change requires restart) | |
| 134 | +#huge_page_size = 0 # zero for system default | |
| 135 | + # (change requires restart) | |
| 136 | +#temp_buffers = 8MB # min 800kB | |
| 137 | +#max_prepared_transactions = 0 # zero disables the feature | |
| 138 | + # (change requires restart) | |
| 139 | +# Caution: it is not advisable to set max_prepared_transactions nonzero unless | |
| 140 | +# you actively intend to use prepared transactions. | |
| 141 | +#work_mem = 4MB # min 64kB | |
| 142 | +#hash_mem_multiplier = 2.0 # 1-1000.0 multiplier on hash table work_mem | |
| 143 | +#maintenance_work_mem = 64MB # min 1MB | |
| 144 | +#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem | |
| 145 | +#logical_decoding_work_mem = 64MB # min 64kB | |
| 146 | +#max_stack_depth = 2MB # min 100kB | |
| 147 | +#shared_memory_type = mmap # the default is the first option | |
| 148 | + # supported by the operating system: | |
| 149 | + # mmap | |
| 150 | + # sysv | |
| 151 | + # windows | |
| 152 | + # (change requires restart) | |
| 153 | +dynamic_shared_memory_type = posix # the default is usually the first option | |
| 154 | + # supported by the operating system: | |
| 155 | + # posix | |
| 156 | + # sysv | |
| 157 | + # windows | |
| 158 | + # mmap | |
| 159 | + # (change requires restart) | |
| 160 | +#min_dynamic_shared_memory = 0MB # (change requires restart) | |
| 161 | +#vacuum_buffer_usage_limit = 256kB # size of vacuum and analyze buffer access strategy ring; | |
| 162 | + # 0 to disable vacuum buffer access strategy; | |
| 163 | + # range 128kB to 16GB | |
| 164 | + | |
| 165 | +# - Disk - | |
| 166 | + | |
| 167 | +#temp_file_limit = -1 # limits per-process temp file space | |
| 168 | + # in kilobytes, or -1 for no limit | |
| 169 | + | |
| 170 | +# - Kernel Resources - | |
| 171 | + | |
| 172 | +#max_files_per_process = 1000 # min 64 | |
| 173 | + # (change requires restart) | |
| 174 | + | |
| 175 | +# - Cost-Based Vacuum Delay - | |
| 176 | + | |
| 177 | +#vacuum_cost_delay = 0 # 0-100 milliseconds (0 disables) | |
| 178 | +#vacuum_cost_page_hit = 1 # 0-10000 credits | |
| 179 | +#vacuum_cost_page_miss = 2 # 0-10000 credits | |
| 180 | +#vacuum_cost_page_dirty = 20 # 0-10000 credits | |
| 181 | +#vacuum_cost_limit = 200 # 1-10000 credits | |
| 182 | + | |
| 183 | +# - Background Writer - | |
| 184 | + | |
| 185 | +#bgwriter_delay = 200ms # 10-10000ms between rounds | |
| 186 | +#bgwriter_lru_maxpages = 100 # max buffers written/round, 0 disables | |
| 187 | +#bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round | |
| 188 | +#bgwriter_flush_after = 512kB # measured in pages, 0 disables | |
| 189 | + | |
| 190 | +# - Asynchronous Behavior - | |
| 191 | + | |
| 192 | +#backend_flush_after = 0 # measured in pages, 0 disables | |
| 193 | +#effective_io_concurrency = 1 # 1-1000; 0 disables prefetching | |
| 194 | +#maintenance_io_concurrency = 10 # 1-1000; 0 disables prefetching | |
| 195 | +#max_worker_processes = 8 # (change requires restart) | |
| 196 | +#max_parallel_workers_per_gather = 2 # limited by max_parallel_workers | |
| 197 | +#max_parallel_maintenance_workers = 2 # limited by max_parallel_workers | |
| 198 | +#max_parallel_workers = 8 # number of max_worker_processes that | |
| 199 | + # can be used in parallel operations | |
| 200 | +#parallel_leader_participation = on | |
| 201 | +#old_snapshot_threshold = -1 # 1min-60d; -1 disables; 0 is immediate | |
| 202 | + # (change requires restart) | |
| 203 | + | |
| 204 | + | |
| 205 | +#------------------------------------------------------------------------------ | |
| 206 | +# WRITE-AHEAD LOG | |
| 207 | +#------------------------------------------------------------------------------ | |
| 208 | + | |
| 209 | +# - Settings - | |
| 210 | + | |
| 211 | +#wal_level = replica # minimal, replica, or logical | |
| 212 | + # (change requires restart) | |
| 213 | +#fsync = on # flush data to disk for crash safety | |
| 214 | + # (turning this off can cause | |
| 215 | + # unrecoverable data corruption) | |
| 216 | +#synchronous_commit = on # synchronization level; | |
| 217 | + # off, local, remote_write, remote_apply, or on | |
| 218 | +#wal_sync_method = fsync # the default is the first option | |
| 219 | + # supported by the operating system: | |
| 220 | + # open_datasync | |
| 221 | + # fdatasync (default on Linux and FreeBSD) | |
| 222 | + # fsync | |
| 223 | + # fsync_writethrough | |
| 224 | + # open_sync | |
| 225 | +#full_page_writes = on # recover from partial page writes | |
| 226 | +#wal_log_hints = off # also do full page writes of non-critical updates | |
| 227 | + # (change requires restart) | |
| 228 | +#wal_compression = off # enables compression of full-page writes; | |
| 229 | + # off, pglz, lz4, zstd, or on | |
| 230 | +#wal_init_zero = on # zero-fill new WAL files | |
| 231 | +#wal_recycle = on # recycle WAL files | |
| 232 | +#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers | |
| 233 | + # (change requires restart) | |
| 234 | +#wal_writer_delay = 200ms # 1-10000 milliseconds | |
| 235 | +#wal_writer_flush_after = 1MB # measured in pages, 0 disables | |
| 236 | +#wal_skip_threshold = 2MB | |
| 237 | + | |
| 238 | +#commit_delay = 0 # range 0-100000, in microseconds | |
| 239 | +#commit_siblings = 5 # range 1-1000 | |
| 240 | + | |
| 241 | +# - Checkpoints - | |
| 242 | + | |
| 243 | +#checkpoint_timeout = 5min # range 30s-1d | |
| 244 | +#checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0 | |
| 245 | +#checkpoint_flush_after = 256kB # measured in pages, 0 disables | |
| 246 | +#checkpoint_warning = 30s # 0 disables | |
| 247 | +max_wal_size = 1GB | |
| 248 | +min_wal_size = 80MB | |
| 249 | + | |
| 250 | +# - Prefetching during recovery - | |
| 251 | + | |
| 252 | +#recovery_prefetch = try # prefetch pages referenced in the WAL? | |
| 253 | +#wal_decode_buffer_size = 512kB # lookahead window used for prefetching | |
| 254 | + # (change requires restart) | |
| 255 | + | |
| 256 | +# - Archiving - | |
| 257 | + | |
| 258 | +#archive_mode = off # enables archiving; off, on, or always | |
| 259 | + # (change requires restart) | |
| 260 | +#archive_library = '' # library to use to archive a WAL file | |
| 261 | + # (empty string indicates archive_command should | |
| 262 | + # be used) | |
| 263 | +#archive_command = '' # command to use to archive a WAL file | |
| 264 | + # placeholders: %p = path of file to archive | |
| 265 | + # %f = file name only | |
| 266 | + # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' | |
| 267 | +#archive_timeout = 0 # force a WAL file switch after this | |
| 268 | + # number of seconds; 0 disables | |
| 269 | + | |
| 270 | +# - Archive Recovery - | |
| 271 | + | |
| 272 | +# These are only used in recovery mode. | |
| 273 | + | |
| 274 | +#restore_command = '' # command to use to restore an archived WAL file | |
| 275 | + # placeholders: %p = path of file to restore | |
| 276 | + # %f = file name only | |
| 277 | + # e.g. 'cp /mnt/server/archivedir/%f %p' | |
| 278 | +#archive_cleanup_command = '' # command to execute at every restartpoint | |
| 279 | +#recovery_end_command = '' # command to execute at completion of recovery | |
| 280 | + | |
| 281 | +# - Recovery Target - | |
| 282 | + | |
| 283 | +# Set these only when performing a targeted recovery. | |
| 284 | + | |
| 285 | +#recovery_target = '' # 'immediate' to end recovery as soon as a | |
| 286 | + # consistent state is reached | |
| 287 | + # (change requires restart) | |
| 288 | +#recovery_target_name = '' # the named restore point to which recovery will proceed | |
| 289 | + # (change requires restart) | |
| 290 | +#recovery_target_time = '' # the time stamp up to which recovery will proceed | |
| 291 | + # (change requires restart) | |
| 292 | +#recovery_target_xid = '' # the transaction ID up to which recovery will proceed | |
| 293 | + # (change requires restart) | |
| 294 | +#recovery_target_lsn = '' # the WAL LSN up to which recovery will proceed | |
| 295 | + # (change requires restart) | |
| 296 | +#recovery_target_inclusive = on # Specifies whether to stop: | |
| 297 | + # just after the specified recovery target (on) | |
| 298 | + # just before the recovery target (off) | |
| 299 | + # (change requires restart) | |
| 300 | +#recovery_target_timeline = 'latest' # 'current', 'latest', or timeline ID | |
| 301 | + # (change requires restart) | |
| 302 | +#recovery_target_action = 'pause' # 'pause', 'promote', 'shutdown' | |
| 303 | + # (change requires restart) | |
| 304 | + | |
| 305 | + | |
| 306 | +#------------------------------------------------------------------------------ | |
| 307 | +# REPLICATION | |
| 308 | +#------------------------------------------------------------------------------ | |
| 309 | + | |
| 310 | +# - Sending Servers - | |
| 311 | + | |
| 312 | +# Set these on the primary and on any standby that will send replication data. | |
| 313 | + | |
| 314 | +#max_wal_senders = 10 # max number of walsender processes | |
| 315 | + # (change requires restart) | |
| 316 | +#max_replication_slots = 10 # max number of replication slots | |
| 317 | + # (change requires restart) | |
| 318 | +#wal_keep_size = 0 # in megabytes; 0 disables | |
| 319 | +#max_slot_wal_keep_size = -1 # in megabytes; -1 disables | |
| 320 | +#wal_sender_timeout = 60s # in milliseconds; 0 disables | |
| 321 | +#track_commit_timestamp = off # collect timestamp of transaction commit | |
| 322 | + # (change requires restart) | |
| 323 | + | |
| 324 | +# - Primary Server - | |
| 325 | + | |
| 326 | +# These settings are ignored on a standby server. | |
| 327 | + | |
| 328 | +#synchronous_standby_names = '' # standby servers that provide sync rep | |
| 329 | + # method to choose sync standbys, number of sync standbys, | |
| 330 | + # and comma-separated list of application_name | |
| 331 | + # from standby(s); '*' = all | |
| 332 | + | |
| 333 | +# - Standby Servers - | |
| 334 | + | |
| 335 | +# These settings are ignored on a primary server. | |
| 336 | + | |
| 337 | +#primary_conninfo = '' # connection string to sending server | |
| 338 | +#primary_slot_name = '' # replication slot on sending server | |
| 339 | +#hot_standby = on # "off" disallows queries during recovery | |
| 340 | + # (change requires restart) | |
| 341 | +#max_standby_archive_delay = 30s # max delay before canceling queries | |
| 342 | + # when reading WAL from archive; | |
| 343 | + # -1 allows indefinite delay | |
| 344 | +#max_standby_streaming_delay = 30s # max delay before canceling queries | |
| 345 | + # when reading streaming WAL; | |
| 346 | + # -1 allows indefinite delay | |
| 347 | +#wal_receiver_create_temp_slot = off # create temp slot if primary_slot_name | |
| 348 | + # is not set | |
| 349 | +#wal_receiver_status_interval = 10s # send replies at least this often | |
| 350 | + # 0 disables | |
| 351 | +#hot_standby_feedback = off # send info from standby to prevent | |
| 352 | + # query conflicts | |
| 353 | +#wal_receiver_timeout = 60s # time that receiver waits for | |
| 354 | + # communication from primary | |
| 355 | + # in milliseconds; 0 disables | |
| 356 | +#wal_retrieve_retry_interval = 5s # time to wait before retrying to | |
| 357 | + # retrieve WAL after a failed attempt | |
| 358 | +#recovery_min_apply_delay = 0 # minimum delay for applying changes during recovery | |
| 359 | + | |
| 360 | +# - Subscribers - | |
| 361 | + | |
| 362 | +# These settings are ignored on a publisher. | |
| 363 | + | |
| 364 | +#max_logical_replication_workers = 4 # taken from max_worker_processes | |
| 365 | + # (change requires restart) | |
| 366 | +#max_sync_workers_per_subscription = 2 # taken from max_logical_replication_workers | |
| 367 | +#max_parallel_apply_workers_per_subscription = 2 # taken from max_logical_replication_workers | |
| 368 | + | |
| 369 | + | |
| 370 | +#------------------------------------------------------------------------------ | |
| 371 | +# QUERY TUNING | |
| 372 | +#------------------------------------------------------------------------------ | |
| 373 | + | |
| 374 | +# - Planner Method Configuration - | |
| 375 | + | |
| 376 | +#enable_async_append = on | |
| 377 | +#enable_bitmapscan = on | |
| 378 | +#enable_gathermerge = on | |
| 379 | +#enable_hashagg = on | |
| 380 | +#enable_hashjoin = on | |
| 381 | +#enable_incremental_sort = on | |
| 382 | +#enable_indexscan = on | |
| 383 | +#enable_indexonlyscan = on | |
| 384 | +#enable_material = on | |
| 385 | +#enable_memoize = on | |
| 386 | +#enable_mergejoin = on | |
| 387 | +#enable_nestloop = on | |
| 388 | +#enable_parallel_append = on | |
| 389 | +#enable_parallel_hash = on | |
| 390 | +#enable_partition_pruning = on | |
| 391 | +#enable_partitionwise_join = off | |
| 392 | +#enable_partitionwise_aggregate = off | |
| 393 | +#enable_presorted_aggregate = on | |
| 394 | +#enable_seqscan = on | |
| 395 | +#enable_sort = on | |
| 396 | +#enable_tidscan = on | |
| 397 | + | |
| 398 | +# - Planner Cost Constants - | |
| 399 | + | |
| 400 | +#seq_page_cost = 1.0 # measured on an arbitrary scale | |
| 401 | +#random_page_cost = 4.0 # same scale as above | |
| 402 | +#cpu_tuple_cost = 0.01 # same scale as above | |
| 403 | +#cpu_index_tuple_cost = 0.005 # same scale as above | |
| 404 | +#cpu_operator_cost = 0.0025 # same scale as above | |
| 405 | +#parallel_setup_cost = 1000.0 # same scale as above | |
| 406 | +#parallel_tuple_cost = 0.1 # same scale as above | |
| 407 | +#min_parallel_table_scan_size = 8MB | |
| 408 | +#min_parallel_index_scan_size = 512kB | |
| 409 | +#effective_cache_size = 4GB | |
| 410 | + | |
| 411 | +#jit_above_cost = 100000 # perform JIT compilation if available | |
| 412 | + # and query more expensive than this; | |
| 413 | + # -1 disables | |
| 414 | +#jit_inline_above_cost = 500000 # inline small functions if query is | |
| 415 | + # more expensive than this; -1 disables | |
| 416 | +#jit_optimize_above_cost = 500000 # use expensive JIT optimizations if | |
| 417 | + # query is more expensive than this; | |
| 418 | + # -1 disables | |
| 419 | + | |
| 420 | +# - Genetic Query Optimizer - | |
| 421 | + | |
| 422 | +#geqo = on | |
| 423 | +#geqo_threshold = 12 | |
| 424 | +#geqo_effort = 5 # range 1-10 | |
| 425 | +#geqo_pool_size = 0 # selects default based on effort | |
| 426 | +#geqo_generations = 0 # selects default based on effort | |
| 427 | +#geqo_selection_bias = 2.0 # range 1.5-2.0 | |
| 428 | +#geqo_seed = 0.0 # range 0.0-1.0 | |
| 429 | + | |
| 430 | +# - Other Planner Options - | |
| 431 | + | |
| 432 | +#default_statistics_target = 100 # range 1-10000 | |
| 433 | +#constraint_exclusion = partition # on, off, or partition | |
| 434 | +#cursor_tuple_fraction = 0.1 # range 0.0-1.0 | |
| 435 | +#from_collapse_limit = 8 | |
| 436 | +#jit = on # allow JIT compilation | |
| 437 | +#join_collapse_limit = 8 # 1 disables collapsing of explicit | |
| 438 | + # JOIN clauses | |
| 439 | +#plan_cache_mode = auto # auto, force_generic_plan or | |
| 440 | + # force_custom_plan | |
| 441 | +#recursive_worktable_factor = 10.0 # range 0.001-1000000 | |
| 442 | + | |
| 443 | + | |
| 444 | +#------------------------------------------------------------------------------ | |
| 445 | +# REPORTING AND LOGGING | |
| 446 | +#------------------------------------------------------------------------------ | |
| 447 | + | |
| 448 | +# - Where to Log - | |
| 449 | + | |
| 450 | +#log_destination = 'stderr' # Valid values are combinations of | |
| 451 | + # stderr, csvlog, jsonlog, syslog, and | |
| 452 | + # eventlog, depending on platform. | |
| 453 | + # csvlog and jsonlog require | |
| 454 | + # logging_collector to be on. | |
| 455 | + | |
| 456 | +# This is used when logging to stderr: | |
| 457 | +#logging_collector = off # Enable capturing of stderr, jsonlog, | |
| 458 | + # and csvlog into log files. Required | |
| 459 | + # to be on for csvlogs and jsonlogs. | |
| 460 | + # (change requires restart) | |
| 461 | + | |
| 462 | +# These are only used if logging_collector is on: | |
| 463 | +#log_directory = 'log' # directory where log files are written, | |
| 464 | + # can be absolute or relative to PGDATA | |
| 465 | +#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, | |
| 466 | + # can include strftime() escapes | |
| 467 | +#log_file_mode = 0600 # creation mode for log files, | |
| 468 | + # begin with 0 to use octal notation | |
| 469 | +#log_rotation_age = 1d # Automatic rotation of logfiles will | |
| 470 | + # happen after that time. 0 disables. | |
| 471 | +#log_rotation_size = 10MB # Automatic rotation of logfiles will | |
| 472 | + # happen after that much log output. | |
| 473 | + # 0 disables. | |
| 474 | +#log_truncate_on_rotation = off # If on, an existing log file with the | |
| 475 | + # same name as the new log file will be | |
| 476 | + # truncated rather than appended to. | |
| 477 | + # But such truncation only occurs on | |
| 478 | + # time-driven rotation, not on restarts | |
| 479 | + # or size-driven rotation. Default is | |
| 480 | + # off, meaning append to existing files | |
| 481 | + # in all cases. | |
| 482 | + | |
| 483 | +# These are relevant when logging to syslog: | |
| 484 | +#syslog_facility = 'LOCAL0' | |
| 485 | +#syslog_ident = 'postgres' | |
| 486 | +#syslog_sequence_numbers = on | |
| 487 | +#syslog_split_messages = on | |
| 488 | + | |
| 489 | +# This is only relevant when logging to eventlog (Windows): | |
| 490 | +# (change requires restart) | |
| 491 | +#event_source = 'PostgreSQL' | |
| 492 | + | |
| 493 | +# - When to Log - | |
| 494 | + | |
| 495 | +#log_min_messages = warning # values in order of decreasing detail: | |
| 496 | + # debug5 | |
| 497 | + # debug4 | |
| 498 | + # debug3 | |
| 499 | + # debug2 | |
| 500 | + # debug1 | |
| 501 | + # info | |
| 502 | + # notice | |
| 503 | + # warning | |
| 504 | + # error | |
| 505 | + # log | |
| 506 | + # fatal | |
| 507 | + # panic | |
| 508 | + | |
| 509 | +#log_min_error_statement = error # values in order of decreasing detail: | |
| 510 | + # debug5 | |
| 511 | + # debug4 | |
| 512 | + # debug3 | |
| 513 | + # debug2 | |
| 514 | + # debug1 | |
| 515 | + # info | |
| 516 | + # notice | |
| 517 | + # warning | |
| 518 | + # error | |
| 519 | + # log | |
| 520 | + # fatal | |
| 521 | + # panic (effectively off) | |
| 522 | + | |
| 523 | +#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements | |
| 524 | + # and their durations, > 0 logs only | |
| 525 | + # statements running at least this number | |
| 526 | + # of milliseconds | |
| 527 | + | |
| 528 | +#log_min_duration_sample = -1 # -1 is disabled, 0 logs a sample of statements | |
| 529 | + # and their durations, > 0 logs only a sample of | |
| 530 | + # statements running at least this number | |
| 531 | + # of milliseconds; | |
| 532 | + # sample fraction is determined by log_statement_sample_rate | |
| 533 | + | |
| 534 | +#log_statement_sample_rate = 1.0 # fraction of logged statements exceeding | |
| 535 | + # log_min_duration_sample to be logged; | |
| 536 | + # 1.0 logs all such statements, 0.0 never logs | |
| 537 | + | |
| 538 | + | |
| 539 | +#log_transaction_sample_rate = 0.0 # fraction of transactions whose statements | |
| 540 | + # are logged regardless of their duration; 1.0 logs all | |
| 541 | + # statements from all transactions, 0.0 never logs | |
| 542 | + | |
| 543 | +#log_startup_progress_interval = 10s # Time between progress updates for | |
| 544 | + # long-running startup operations. | |
| 545 | + # 0 disables the feature, > 0 indicates | |
| 546 | + # the interval in milliseconds. | |
| 547 | + | |
| 548 | +# - What to Log - | |
| 549 | + | |
| 550 | +#debug_print_parse = off | |
| 551 | +#debug_print_rewritten = off | |
| 552 | +#debug_print_plan = off | |
| 553 | +#debug_pretty_print = on | |
| 554 | +#log_autovacuum_min_duration = 10min # log autovacuum activity; | |
| 555 | + # -1 disables, 0 logs all actions and | |
| 556 | + # their durations, > 0 logs only | |
| 557 | + # actions running at least this number | |
| 558 | + # of milliseconds. | |
| 559 | +#log_checkpoints = on | |
| 560 | +#log_connections = off | |
| 561 | +#log_disconnections = off | |
| 562 | +#log_duration = off | |
| 563 | +#log_error_verbosity = default # terse, default, or verbose messages | |
| 564 | +#log_hostname = off | |
| 565 | +#log_line_prefix = '%m [%p] ' # special values: | |
| 566 | + # %a = application name | |
| 567 | + # %u = user name | |
| 568 | + # %d = database name | |
| 569 | + # %r = remote host and port | |
| 570 | + # %h = remote host | |
| 571 | + # %b = backend type | |
| 572 | + # %p = process ID | |
| 573 | + # %P = process ID of parallel group leader | |
| 574 | + # %t = timestamp without milliseconds | |
| 575 | + # %m = timestamp with milliseconds | |
| 576 | + # %n = timestamp with milliseconds (as a Unix epoch) | |
| 577 | + # %Q = query ID (0 if none or not computed) | |
| 578 | + # %i = command tag | |
| 579 | + # %e = SQL state | |
| 580 | + # %c = session ID | |
| 581 | + # %l = session line number | |
| 582 | + # %s = session start timestamp | |
| 583 | + # %v = virtual transaction ID | |
| 584 | + # %x = transaction ID (0 if none) | |
| 585 | + # %q = stop here in non-session | |
| 586 | + # processes | |
| 587 | + # %% = '%' | |
| 588 | + # e.g. '<%u%%%d> ' | |
| 589 | +#log_lock_waits = off # log lock waits >= deadlock_timeout | |
| 590 | +#log_recovery_conflict_waits = off # log standby recovery conflict waits | |
| 591 | + # >= deadlock_timeout | |
| 592 | +#log_parameter_max_length = -1 # when logging statements, limit logged | |
| 593 | + # bind-parameter values to N bytes; | |
| 594 | + # -1 means print in full, 0 disables | |
| 595 | +#log_parameter_max_length_on_error = 0 # when logging an error, limit logged | |
| 596 | + # bind-parameter values to N bytes; | |
| 597 | + # -1 means print in full, 0 disables | |
| 598 | +#log_statement = 'none' # none, ddl, mod, all | |
| 599 | +#log_replication_commands = off | |
| 600 | +#log_temp_files = -1 # log temporary files equal or larger | |
| 601 | + # than the specified size in kilobytes; | |
| 602 | + # -1 disables, 0 logs all temp files | |
| 603 | +log_timezone = UTC | |
| 604 | + | |
| 605 | +# - Process Title - | |
| 606 | + | |
| 607 | +#cluster_name = '' # added to process titles if nonempty | |
| 608 | + # (change requires restart) | |
| 609 | +#update_process_title = on | |
| 610 | + | |
| 611 | + | |
| 612 | +#------------------------------------------------------------------------------ | |
| 613 | +# STATISTICS | |
| 614 | +#------------------------------------------------------------------------------ | |
| 615 | + | |
| 616 | +# - Cumulative Query and Index Statistics - | |
| 617 | + | |
| 618 | +#track_activities = on | |
| 619 | +#track_activity_query_size = 1024 # (change requires restart) | |
| 620 | +#track_counts = on | |
| 621 | +#track_io_timing = off | |
| 622 | +#track_wal_io_timing = off | |
| 623 | +#track_functions = none # none, pl, all | |
| 624 | +#stats_fetch_consistency = cache # cache, none, snapshot | |
| 625 | + | |
| 626 | + | |
| 627 | +# - Monitoring - | |
| 628 | + | |
| 629 | +#compute_query_id = auto | |
| 630 | +#log_statement_stats = off | |
| 631 | +#log_parser_stats = off | |
| 632 | +#log_planner_stats = off | |
| 633 | +#log_executor_stats = off | |
| 634 | + | |
| 635 | + | |
| 636 | +#------------------------------------------------------------------------------ | |
| 637 | +# AUTOVACUUM | |
| 638 | +#------------------------------------------------------------------------------ | |
| 639 | + | |
| 640 | +#autovacuum = on # Enable autovacuum subprocess? 'on' | |
| 641 | + # requires track_counts to also be on. | |
| 642 | +#autovacuum_max_workers = 3 # max number of autovacuum subprocesses | |
| 643 | + # (change requires restart) | |
| 644 | +#autovacuum_naptime = 1min # time between autovacuum runs | |
| 645 | +#autovacuum_vacuum_threshold = 50 # min number of row updates before | |
| 646 | + # vacuum | |
| 647 | +#autovacuum_vacuum_insert_threshold = 1000 # min number of row inserts | |
| 648 | + # before vacuum; -1 disables insert | |
| 649 | + # vacuums | |
| 650 | +#autovacuum_analyze_threshold = 50 # min number of row updates before | |
| 651 | + # analyze | |
| 652 | +#autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum | |
| 653 | +#autovacuum_vacuum_insert_scale_factor = 0.2 # fraction of inserts over table | |
| 654 | + # size before insert vacuum | |
| 655 | +#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze | |
| 656 | +#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum | |
| 657 | + # (change requires restart) | |
| 658 | +#autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age | |
| 659 | + # before forced vacuum | |
| 660 | + # (change requires restart) | |
| 661 | +#autovacuum_vacuum_cost_delay = 2ms # default vacuum cost delay for | |
| 662 | + # autovacuum, in milliseconds; | |
| 663 | + # -1 means use vacuum_cost_delay | |
| 664 | +#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for | |
| 665 | + # autovacuum, -1 means use | |
| 666 | + # vacuum_cost_limit | |
| 667 | + | |
| 668 | + | |
| 669 | +#------------------------------------------------------------------------------ | |
| 670 | +# CLIENT CONNECTION DEFAULTS | |
| 671 | +#------------------------------------------------------------------------------ | |
| 672 | + | |
| 673 | +# - Statement Behavior - | |
| 674 | + | |
| 675 | +#client_min_messages = notice # values in order of decreasing detail: | |
| 676 | + # debug5 | |
| 677 | + # debug4 | |
| 678 | + # debug3 | |
| 679 | + # debug2 | |
| 680 | + # debug1 | |
| 681 | + # log | |
| 682 | + # notice | |
| 683 | + # warning | |
| 684 | + # error | |
| 685 | +#search_path = '"$user", public' # schema names | |
| 686 | +#row_security = on | |
| 687 | +#default_table_access_method = 'heap' | |
| 688 | +#default_tablespace = '' # a tablespace name, '' uses the default | |
| 689 | +#default_toast_compression = 'pglz' # 'pglz' or 'lz4' | |
| 690 | +#temp_tablespaces = '' # a list of tablespace names, '' uses | |
| 691 | + # only default tablespace | |
| 692 | +#check_function_bodies = on | |
| 693 | +#default_transaction_isolation = 'read committed' | |
| 694 | +#default_transaction_read_only = off | |
| 695 | +#default_transaction_deferrable = off | |
| 696 | +#session_replication_role = 'origin' | |
| 697 | +#statement_timeout = 0 # in milliseconds, 0 is disabled | |
| 698 | +#lock_timeout = 0 # in milliseconds, 0 is disabled | |
| 699 | +#idle_in_transaction_session_timeout = 0 # in milliseconds, 0 is disabled | |
| 700 | +#idle_session_timeout = 0 # in milliseconds, 0 is disabled | |
| 701 | +#vacuum_freeze_table_age = 150000000 | |
| 702 | +#vacuum_freeze_min_age = 50000000 | |
| 703 | +#vacuum_failsafe_age = 1600000000 | |
| 704 | +#vacuum_multixact_freeze_table_age = 150000000 | |
| 705 | +#vacuum_multixact_freeze_min_age = 5000000 | |
| 706 | +#vacuum_multixact_failsafe_age = 1600000000 | |
| 707 | +#bytea_output = 'hex' # hex, escape | |
| 708 | +#xmlbinary = 'base64' | |
| 709 | +#xmloption = 'content' | |
| 710 | +#gin_pending_list_limit = 4MB | |
| 711 | +#createrole_self_grant = '' # set and/or inherit | |
| 712 | + | |
| 713 | +# - Locale and Formatting - | |
| 714 | + | |
| 715 | +datestyle = 'iso, mdy' | |
| 716 | +#intervalstyle = 'postgres' | |
| 717 | +timezone = UTC | |
| 718 | +#timezone_abbreviations = 'Default' # Select the set of available time zone | |
| 719 | + # abbreviations. Currently, there are | |
| 720 | + # Default | |
| 721 | + # Australia (historical usage) | |
| 722 | + # India | |
| 723 | + # You can create your own file in | |
| 724 | + # share/timezonesets/. | |
| 725 | +#extra_float_digits = 1 # min -15, max 3; any value >0 actually | |
| 726 | + # selects precise output mode | |
| 727 | +#client_encoding = sql_ascii # actually, defaults to database | |
| 728 | + # encoding | |
| 729 | + | |
| 730 | +# These settings are initialized by initdb, but they can be changed. | |
| 731 | +lc_messages = 'en_US.utf8' # locale for system error message | |
| 732 | + # strings | |
| 733 | +lc_monetary = 'en_US.utf8' # locale for monetary formatting | |
| 734 | +lc_numeric = 'en_US.utf8' # locale for number formatting | |
| 735 | +lc_time = 'en_US.utf8' # locale for time formatting | |
| 736 | + | |
| 737 | +#icu_validation_level = warning # report ICU locale validation | |
| 738 | + # errors at the given level | |
| 739 | + | |
| 740 | +# default configuration for text search | |
| 741 | +default_text_search_config = 'pg_catalog.english' | |
| 742 | + | |
| 743 | +# - Shared Library Preloading - | |
| 744 | + | |
| 745 | +#local_preload_libraries = '' | |
| 746 | +#session_preload_libraries = '' | |
| 747 | +#shared_preload_libraries = '' # (change requires restart) | |
| 748 | +#jit_provider = 'llvmjit' # JIT library to use | |
| 749 | + | |
| 750 | +# - Other Defaults - | |
| 751 | + | |
| 752 | +#dynamic_library_path = '$libdir' | |
| 753 | +#gin_fuzzy_search_limit = 0 | |
| 754 | + | |
| 755 | + | |
| 756 | +#------------------------------------------------------------------------------ | |
| 757 | +# LOCK MANAGEMENT | |
| 758 | +#------------------------------------------------------------------------------ | |
| 759 | + | |
| 760 | +#deadlock_timeout = 1s | |
| 761 | +#max_locks_per_transaction = 64 # min 10 | |
| 762 | + # (change requires restart) | |
| 763 | +#max_pred_locks_per_transaction = 64 # min 10 | |
| 764 | + # (change requires restart) | |
| 765 | +#max_pred_locks_per_relation = -2 # negative values mean | |
| 766 | + # (max_pred_locks_per_transaction | |
| 767 | + # / -max_pred_locks_per_relation) - 1 | |
| 768 | +#max_pred_locks_per_page = 2 # min 0 | |
| 769 | + | |
| 770 | + | |
| 771 | +#------------------------------------------------------------------------------ | |
| 772 | +# VERSION AND PLATFORM COMPATIBILITY | |
| 773 | +#------------------------------------------------------------------------------ | |
| 774 | + | |
| 775 | +# - Previous PostgreSQL Versions - | |
| 776 | + | |
| 777 | +#array_nulls = on | |
| 778 | +#backslash_quote = safe_encoding # on, off, or safe_encoding | |
| 779 | +#escape_string_warning = on | |
| 780 | +#lo_compat_privileges = off | |
| 781 | +#quote_all_identifiers = off | |
| 782 | +#standard_conforming_strings = on | |
| 783 | +#synchronize_seqscans = on | |
| 784 | + | |
| 785 | +# - Other Platforms and Clients - | |
| 786 | + | |
| 787 | +#transform_null_equals = off | |
| 788 | + | |
| 789 | + | |
| 790 | +#------------------------------------------------------------------------------ | |
| 791 | +# ERROR HANDLING | |
| 792 | +#------------------------------------------------------------------------------ | |
| 793 | + | |
| 794 | +#exit_on_error = off # terminate session on any error? | |
| 795 | +#restart_after_crash = on # reinitialize after backend crash? | |
| 796 | +#data_sync_retry = off # retry or panic on failure to fsync | |
| 797 | + # data? | |
| 798 | + # (change requires restart) | |
| 799 | +#recovery_init_sync_method = fsync # fsync, syncfs (Linux 5.8+) | |
| 800 | + | |
| 801 | + | |
| 802 | +#------------------------------------------------------------------------------ | |
| 803 | +# CONFIG FILE INCLUDES | |
| 804 | +#------------------------------------------------------------------------------ | |
| 805 | + | |
| 806 | +# These options allow settings to be loaded from files other than the | |
| 807 | +# default postgresql.conf. Note that these are directives, not variable | |
| 808 | +# assignments, so they can usefully be given more than once. | |
| 809 | + | |
| 810 | +#include_dir = '...' # include files ending in '.conf' from | |
| 811 | + # a directory, e.g., 'conf.d' | |
| 812 | +#include_if_exists = '...' # include file only if it exists | |
| 813 | +#include = '...' # include file | |
| 814 | + | |
| 815 | + | |
| 816 | +#------------------------------------------------------------------------------ | |
| 817 | +# CUSTOMIZED OPTIONS | |
| 818 | +#------------------------------------------------------------------------------ | |
| 819 | + | |
| 820 | +# Add settings for extensions here |
| @@ -0,0 +1 @@ | ||
| 1 | +/usr/local/bin/postgres |
| @@ -0,0 +1,4 @@ | ||
| 1 | +__pycache__ | |
| 2 | +*.sqlite3 | |
| 3 | +staticfiles | |
| 4 | +.env |
| @@ -0,0 +1,37 @@ | ||
| 1 | +server { | |
| 2 | + | |
| 3 | + location / { | |
| 4 | + proxy_set_header X-Real-IP $remote_addr; | |
| 5 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| 6 | + proxy_set_header Host $http_host; | |
| 7 | + proxy_set_header Connection "Upgrade"; | |
| 8 | + proxy_set_header Upgrade $http_upgrade; | |
| 9 | + proxy_set_header X-NginX-Proxy true; | |
| 10 | + client_max_body_size 5000M; | |
| 11 | + | |
| 12 | + # WebSocket requests | |
| 13 | + if ($http_upgrade = "websocket") { | |
| 14 | + proxy_pass http://app:8001; # Daphne runs on port 8001 | |
| 15 | + } | |
| 16 | + | |
| 17 | + # Normal HTTP requests | |
| 18 | + if ($http_upgrade != "websocket") { | |
| 19 | + proxy_pass http://app:8000; # Gunicorn runs on port 8000 | |
| 20 | + } | |
| 21 | + | |
| 22 | + proxy_redirect off; | |
| 23 | + } | |
| 24 | + | |
| 25 | + location /static/ { | |
| 26 | + alias /var/www/staticfiles/; | |
| 27 | + } | |
| 28 | + | |
| 29 | + # https://github.com/cobusc/django-protected-media | |
| 30 | + location /media/ { | |
| 31 | + alias /var/www/media/; | |
| 32 | + } | |
| 33 | + location /internal/ { | |
| 34 | + # internal; | |
| 35 | + alias /var/www/protected/; | |
| 36 | + } | |
| 37 | +} |
No content changes (mode or rename only).
| @@ -0,0 +1,16 @@ | ||
| 1 | +""" | |
| 2 | +ASGI config for app project. | |
| 3 | + | |
| 4 | +It exposes the ASGI callable as a module-level variable named ``application``. | |
| 5 | + | |
| 6 | +For more information on this file, see | |
| 7 | +https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ | |
| 8 | +""" | |
| 9 | + | |
| 10 | +import os | |
| 11 | + | |
| 12 | +from django.core.asgi import get_asgi_application | |
| 13 | + | |
| 14 | +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') | |
| 15 | + | |
| 16 | +application = get_asgi_application() |
| @@ -0,0 +1,135 @@ | ||
| 1 | +""" | |
| 2 | +Django settings for app project. | |
| 3 | + | |
| 4 | +Generated by 'django-admin startproject' using Django 4.1.4. | |
| 5 | + | |
| 6 | +For more information on this file, see | |
| 7 | +https://docs.djangoproject.com/en/4.1/topics/settings/ | |
| 8 | + | |
| 9 | +For the full list of settings and their values, see | |
| 10 | +https://docs.djangoproject.com/en/4.1/ref/settings/ | |
| 11 | +""" | |
| 12 | + | |
| 13 | +from pathlib import Path | |
| 14 | +import dotenv | |
| 15 | +import os | |
| 16 | + | |
| 17 | +dotenv.load_dotenv() | |
| 18 | + | |
| 19 | +# Build paths inside the project like this: BASE_DIR / 'subdir'. | |
| 20 | +BASE_DIR = Path(__file__).resolve().parent.parent | |
| 21 | + | |
| 22 | + | |
| 23 | +# Quick-start development settings - unsuitable for production | |
| 24 | +# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ | |
| 25 | + | |
| 26 | +# SECURITY WARNING: keep the secret key used in production secret! | |
| 27 | +SECRET_KEY = os.getenv("DJANGO_SECRET") | |
| 28 | + | |
| 29 | +# SECURITY WARNING: don't run with debug turned on in production! | |
| 30 | +DEBUG = True | |
| 31 | + | |
| 32 | +ALLOWED_HOSTS = [] | |
| 33 | + | |
| 34 | + | |
| 35 | +# Application definition | |
| 36 | + | |
| 37 | +INSTALLED_APPS = [ | |
| 38 | + 'django.contrib.admin', | |
| 39 | + 'django.contrib.auth', | |
| 40 | + 'django.contrib.contenttypes', | |
| 41 | + 'django.contrib.sessions', | |
| 42 | + 'django.contrib.messages', | |
| 43 | + 'django.contrib.staticfiles', | |
| 44 | + 'smartwatch', | |
| 45 | + 'live_logger' | |
| 46 | +] | |
| 47 | + | |
| 48 | +MIDDLEWARE = [ | |
| 49 | + 'django.middleware.security.SecurityMiddleware', | |
| 50 | + 'django.contrib.sessions.middleware.SessionMiddleware', | |
| 51 | + 'django.middleware.common.CommonMiddleware', | |
| 52 | + 'django.middleware.csrf.CsrfViewMiddleware', | |
| 53 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
| 54 | + 'django.contrib.messages.middleware.MessageMiddleware', | |
| 55 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
| 56 | + 'live_logger.middleware.RequestLoggingMiddleware' | |
| 57 | +] | |
| 58 | + | |
| 59 | +ROOT_URLCONF = 'app.urls' | |
| 60 | + | |
| 61 | +TEMPLATES = [ | |
| 62 | + { | |
| 63 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
| 64 | + 'DIRS': [], | |
| 65 | + 'APP_DIRS': True, | |
| 66 | + 'OPTIONS': { | |
| 67 | + 'context_processors': [ | |
| 68 | + 'django.template.context_processors.debug', | |
| 69 | + 'django.template.context_processors.request', | |
| 70 | + 'django.contrib.auth.context_processors.auth', | |
| 71 | + 'django.contrib.messages.context_processors.messages', | |
| 72 | + ], | |
| 73 | + }, | |
| 74 | + }, | |
| 75 | +] | |
| 76 | + | |
| 77 | +WSGI_APPLICATION = 'app.wsgi.application' | |
| 78 | + | |
| 79 | + | |
| 80 | +# Database | |
| 81 | +# https://docs.djangoproject.com/en/4.1/ref/settings/#databases | |
| 82 | + | |
| 83 | +DATABASES = { | |
| 84 | + 'default': { | |
| 85 | + 'ENGINE': 'django.db.backends.postgresql', | |
| 86 | + 'NAME': os.getenv("POSTGRES_DB"), | |
| 87 | + "USER": os.getenv("POSTGRES_USER"), | |
| 88 | + "PASSWORD": os.getenv("POSTGRES_PASSWORD"), | |
| 89 | + "HOST": os.getenv("POSTGRES_HOST"), | |
| 90 | + "PORT": os.getenv("POSTGRES_PORT") | |
| 91 | + } | |
| 92 | +} | |
| 93 | + | |
| 94 | + | |
| 95 | +# Password validation | |
| 96 | +# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators | |
| 97 | + | |
| 98 | +AUTH_PASSWORD_VALIDATORS = [ | |
| 99 | + { | |
| 100 | + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | |
| 101 | + }, | |
| 102 | + { | |
| 103 | + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | |
| 104 | + }, | |
| 105 | + { | |
| 106 | + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | |
| 107 | + }, | |
| 108 | + { | |
| 109 | + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | |
| 110 | + }, | |
| 111 | +] | |
| 112 | + | |
| 113 | + | |
| 114 | +# Internationalization | |
| 115 | +# https://docs.djangoproject.com/en/4.1/topics/i18n/ | |
| 116 | + | |
| 117 | +LANGUAGE_CODE = 'en-us' | |
| 118 | + | |
| 119 | +TIME_ZONE = 'UTC' | |
| 120 | + | |
| 121 | +USE_I18N = True | |
| 122 | + | |
| 123 | +USE_TZ = True | |
| 124 | + | |
| 125 | + | |
| 126 | +# Static files (CSS, JavaScript, Images) | |
| 127 | +# https://docs.djangoproject.com/en/4.1/howto/static-files/ | |
| 128 | + | |
| 129 | +STATIC_URL = 'static/' | |
| 130 | +STATIC_ROOT = BASE_DIR / 'staticfiles' | |
| 131 | + | |
| 132 | +# Default primary key field type | |
| 133 | +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field | |
| 134 | + | |
| 135 | +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
| @@ -0,0 +1,21 @@ | ||
| 1 | +"""app URL Configuration | |
| 2 | + | |
| 3 | +The `urlpatterns` list routes URLs to views. For more information please see: | |
| 4 | + https://docs.djangoproject.com/en/4.1/topics/http/urls/ | |
| 5 | +Examples: | |
| 6 | +Function views | |
| 7 | + 1. Add an import: from my_app import views | |
| 8 | + 2. Add a URL to urlpatterns: path('', views.home, name='home') | |
| 9 | +Class-based views | |
| 10 | + 1. Add an import: from other_app.views import Home | |
| 11 | + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') | |
| 12 | +Including another URLconf | |
| 13 | + 1. Import the include() function: from django.urls import include, path | |
| 14 | + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) | |
| 15 | +""" | |
| 16 | +from django.contrib import admin | |
| 17 | +from django.urls import path | |
| 18 | + | |
| 19 | +urlpatterns = [ | |
| 20 | + path('admin/', admin.site.urls), | |
| 21 | +] |
| @@ -0,0 +1,16 @@ | ||
| 1 | +""" | |
| 2 | +WSGI config for app project. | |
| 3 | + | |
| 4 | +It exposes the WSGI callable as a module-level variable named ``application``. | |
| 5 | + | |
| 6 | +For more information on this file, see | |
| 7 | +https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ | |
| 8 | +""" | |
| 9 | + | |
| 10 | +import os | |
| 11 | + | |
| 12 | +from django.core.wsgi import get_wsgi_application | |
| 13 | + | |
| 14 | +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') | |
| 15 | + | |
| 16 | +application = get_wsgi_application() |
| @@ -0,0 +1,14 @@ | ||
| 1 | +FROM python:3.10.12-slim | |
| 2 | +RUN apt update && apt install xpdf -y | |
| 3 | + | |
| 4 | +ENV PYTHONDONTWRITEBYTECODE=1 | |
| 5 | +ENV PYTHONUNBUFFERED=1 | |
| 6 | + | |
| 7 | +COPY requirements.txt . | |
| 8 | +RUN python -m pip install --upgrade pip | |
| 9 | +RUN pip install -r requirements.txt | |
| 10 | + | |
| 11 | +WORKDIR /code | |
| 12 | +COPY . . | |
| 13 | + | |
| 14 | +CMD ["python", "manage.py", "smartwatch"] |
No content changes (mode or rename only).
| @@ -0,0 +1,16 @@ | ||
| 1 | +from django.contrib import admin | |
| 2 | +from . import models | |
| 3 | + | |
| 4 | +# Register your models here. | |
| 5 | +@admin.register(models.Location) | |
| 6 | +class LocationAdmin(admin.ModelAdmin): | |
| 7 | + list_display = ('ip', 'city', 'region', 'country', 'loc', 'org', 'postal', 'timezone', 'bogon', 'success') | |
| 8 | + | |
| 9 | +@admin.register(models.Log) | |
| 10 | +class LogAdmin(admin.ModelAdmin): | |
| 11 | + list_display = ('endpoint', 'location', 'user', 'start_time', 'end_time') | |
| 12 | + | |
| 13 | + @admin.display() | |
| 14 | + def endpoint(self, obj): | |
| 15 | + return obj.meta['PATH_INFO'] | |
| 16 | + |
| @@ -0,0 +1,6 @@ | ||
| 1 | +from django.apps import AppConfig | |
| 2 | + | |
| 3 | + | |
| 4 | +class LiveLoggerConfig(AppConfig): | |
| 5 | + default_auto_field = 'django.db.models.BigAutoField' | |
| 6 | + name = 'live_logger' |
| @@ -0,0 +1,29 @@ | ||
| 1 | +from channels.generic.websocket import AsyncWebsocketConsumer | |
| 2 | +from django.core import serializers | |
| 3 | +from asgiref.sync import async_to_sync, sync_to_async | |
| 4 | +from .models import Log | |
| 5 | +from pprint import pprint | |
| 6 | +import json | |
| 7 | +from . import settings | |
| 8 | +from .serializers import LogSerializer | |
| 9 | + | |
| 10 | +class LogConsumer(AsyncWebsocketConsumer): | |
| 11 | + async def connect(self): | |
| 12 | + if not self.scope['user'].is_staff: | |
| 13 | + await self.close() | |
| 14 | + return | |
| 15 | + print(self.scope['user']) | |
| 16 | + await self.accept() | |
| 17 | + logs = await sync_to_async(self.fetch_logs)() | |
| 18 | + # await self.send(json.dumps({'type': 'logs', 'data': logs})) | |
| 19 | + await self.send(json.dumps({'type': 'logs', 'data': logs})) | |
| 20 | + | |
| 21 | + def fetch_logs(self, start=0, end=settings.LIVE_LOGGER_PAGINATION) -> dict: | |
| 22 | + logs = Log.objects.all().order_by('-id').prefetch_related('location', 'user')[start:end] | |
| 23 | + return LogSerializer(logs, many=True).data | |
| 24 | + | |
| 25 | + async def disconnect(self, close_code): | |
| 26 | + print('Disconnected!') | |
| 27 | + | |
| 28 | + async def receive(self, text_data): | |
| 29 | + print('Received:', text_data) |
| @@ -0,0 +1,33 @@ | ||
| 1 | +import datetime | |
| 2 | +from threading import Thread | |
| 3 | +from live_logger import settings | |
| 4 | +from .models import Log | |
| 5 | + | |
| 6 | + | |
| 7 | +class RequestLoggingMiddleware: | |
| 8 | + def __init__(self, get_response): | |
| 9 | + self.get_response = get_response | |
| 10 | + | |
| 11 | + def __call__(self, request): | |
| 12 | + # Code to be executed for each request before | |
| 13 | + # the view (and later middleware) are called. | |
| 14 | + # request.log = Log.objects.create(meta=request.META) | |
| 15 | + # Thread(target=Log.objects.create, kwargs={'meta': request.META}).start() | |
| 16 | + for ignore in settings.LIVE_LOGGER_IGNORED_PATHS: | |
| 17 | + if ignore in request.path: | |
| 18 | + return self.get_response(request) | |
| 19 | + request.log = Log(meta=request.META) | |
| 20 | + | |
| 21 | + response = self.get_response(request) | |
| 22 | + | |
| 23 | + # Code to be executed for each request/response after | |
| 24 | + # the view is called. | |
| 25 | + # request.log.duration = time.time() - start | |
| 26 | + request.log.user = request.user if request.user.is_authenticated else None | |
| 27 | + request.log.start_time = datetime.datetime.now( | |
| 28 | + tz=datetime.timezone.utc) | |
| 29 | + request.log.end_time = datetime.datetime.now(tz=datetime.timezone.utc) | |
| 30 | + request.log.status_code = response.status_code | |
| 31 | + Thread(target=request.log.save, daemon=True).start() | |
| 32 | + | |
| 33 | + return response |
| @@ -0,0 +1,43 @@ | ||
| 1 | +# Generated by Django 5.0.6 on 2024-05-16 03:41 | |
| 2 | + | |
| 3 | +import django.db.models.deletion | |
| 4 | +from django.conf import settings | |
| 5 | +from django.db import migrations, models | |
| 6 | + | |
| 7 | + | |
| 8 | +class Migration(migrations.Migration): | |
| 9 | + | |
| 10 | + initial = True | |
| 11 | + | |
| 12 | + dependencies = [ | |
| 13 | + migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
| 14 | + ] | |
| 15 | + | |
| 16 | + operations = [ | |
| 17 | + migrations.CreateModel( | |
| 18 | + name='Location', | |
| 19 | + fields=[ | |
| 20 | + ('ip', models.GenericIPAddressField(primary_key=True, serialize=False)), | |
| 21 | + ('city', models.CharField(max_length=100, null=True)), | |
| 22 | + ('region', models.CharField(max_length=100, null=True)), | |
| 23 | + ('country', models.CharField(max_length=100, null=True)), | |
| 24 | + ('loc', models.CharField(max_length=60, null=True)), | |
| 25 | + ('org', models.CharField(max_length=100, null=True)), | |
| 26 | + ('postal', models.CharField(max_length=20, null=True)), | |
| 27 | + ('timezone', models.CharField(max_length=50, null=True)), | |
| 28 | + ], | |
| 29 | + ), | |
| 30 | + migrations.CreateModel( | |
| 31 | + name='Log', | |
| 32 | + fields=[ | |
| 33 | + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
| 34 | + ('meta', models.JSONField()), | |
| 35 | + ('messages', models.JSONField(default=list)), | |
| 36 | + ('json', models.JSONField(default=dict)), | |
| 37 | + ('timestamp', models.DateTimeField(auto_now_add=True)), | |
| 38 | + ('is_new', models.BooleanField(default=True)), | |
| 39 | + ('loc', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='live_logger.location')), | |
| 40 | + ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), | |
| 41 | + ], | |
| 42 | + ), | |
| 43 | + ] |
| @@ -0,0 +1,27 @@ | ||
| 1 | +# Generated by Django 5.0.6 on 2024-05-16 04:12 | |
| 2 | + | |
| 3 | +from django.db import migrations, models | |
| 4 | + | |
| 5 | + | |
| 6 | +class Migration(migrations.Migration): | |
| 7 | + | |
| 8 | + dependencies = [ | |
| 9 | + ('live_logger', '0001_initial'), | |
| 10 | + ] | |
| 11 | + | |
| 12 | + operations = [ | |
| 13 | + migrations.RemoveField( | |
| 14 | + model_name='log', | |
| 15 | + name='timestamp', | |
| 16 | + ), | |
| 17 | + migrations.AddField( | |
| 18 | + model_name='log', | |
| 19 | + name='end_time', | |
| 20 | + field=models.DateTimeField(null=True), | |
| 21 | + ), | |
| 22 | + migrations.AddField( | |
| 23 | + model_name='log', | |
| 24 | + name='start_time', | |
| 25 | + field=models.DateTimeField(null=True), | |
| 26 | + ), | |
| 27 | + ] |
| @@ -0,0 +1,36 @@ | ||
| 1 | +# Generated by Django 5.0.6 on 2024-05-16 05:02 | |
| 2 | + | |
| 3 | +import django.utils.timezone | |
| 4 | +from django.db import migrations, models | |
| 5 | + | |
| 6 | + | |
| 7 | +class Migration(migrations.Migration): | |
| 8 | + | |
| 9 | + dependencies = [ | |
| 10 | + ('live_logger', '0002_remove_log_timestamp_log_end_time_log_start_time'), | |
| 11 | + ] | |
| 12 | + | |
| 13 | + operations = [ | |
| 14 | + migrations.AddField( | |
| 15 | + model_name='location', | |
| 16 | + name='bogon', | |
| 17 | + field=models.BooleanField(default=False), | |
| 18 | + ), | |
| 19 | + migrations.AddField( | |
| 20 | + model_name='location', | |
| 21 | + name='success', | |
| 22 | + field=models.BooleanField(default=False), | |
| 23 | + ), | |
| 24 | + migrations.AlterField( | |
| 25 | + model_name='log', | |
| 26 | + name='end_time', | |
| 27 | + field=models.DateTimeField(default=django.utils.timezone.now), | |
| 28 | + preserve_default=False, | |
| 29 | + ), | |
| 30 | + migrations.AlterField( | |
| 31 | + model_name='log', | |
| 32 | + name='start_time', | |
| 33 | + field=models.DateTimeField(default=django.utils.timezone.now), | |
| 34 | + preserve_default=False, | |
| 35 | + ), | |
| 36 | + ] |
| @@ -0,0 +1,23 @@ | ||
| 1 | +# Generated by Django 5.0.6 on 2024-05-16 05:04 | |
| 2 | + | |
| 3 | +from django.db import migrations, models | |
| 4 | + | |
| 5 | + | |
| 6 | +class Migration(migrations.Migration): | |
| 7 | + | |
| 8 | + dependencies = [ | |
| 9 | + ('live_logger', '0003_location_bogon_location_success_alter_log_end_time_and_more'), | |
| 10 | + ] | |
| 11 | + | |
| 12 | + operations = [ | |
| 13 | + migrations.AlterField( | |
| 14 | + model_name='log', | |
| 15 | + name='end_time', | |
| 16 | + field=models.DateTimeField(null=True), | |
| 17 | + ), | |
| 18 | + migrations.AlterField( | |
| 19 | + model_name='log', | |
| 20 | + name='start_time', | |
| 21 | + field=models.DateTimeField(null=True), | |
| 22 | + ), | |
| 23 | + ] |
| @@ -0,0 +1,26 @@ | ||
| 1 | +# Generated by Django 5.0.6 on 2024-05-16 13:13 | |
| 2 | + | |
| 3 | +import django.utils.timezone | |
| 4 | +from django.db import migrations, models | |
| 5 | + | |
| 6 | + | |
| 7 | +class Migration(migrations.Migration): | |
| 8 | + | |
| 9 | + dependencies = [ | |
| 10 | + ('live_logger', '0004_alter_log_end_time_alter_log_start_time'), | |
| 11 | + ] | |
| 12 | + | |
| 13 | + operations = [ | |
| 14 | + migrations.AlterField( | |
| 15 | + model_name='log', | |
| 16 | + name='end_time', | |
| 17 | + field=models.DateTimeField(default=django.utils.timezone.now), | |
| 18 | + preserve_default=False, | |
| 19 | + ), | |
| 20 | + migrations.AlterField( | |
| 21 | + model_name='log', | |
| 22 | + name='start_time', | |
| 23 | + field=models.DateTimeField(default=django.utils.timezone.now), | |
| 24 | + preserve_default=False, | |
| 25 | + ), | |
| 26 | + ] |
| @@ -0,0 +1,22 @@ | ||
| 1 | +# Generated by Django 5.0.6 on 2024-05-18 02:00 | |
| 2 | + | |
| 3 | +from django.db import migrations | |
| 4 | + | |
| 5 | + | |
| 6 | +class Migration(migrations.Migration): | |
| 7 | + | |
| 8 | + dependencies = [ | |
| 9 | + ('live_logger', '0005_alter_log_end_time_alter_log_start_time'), | |
| 10 | + ] | |
| 11 | + | |
| 12 | + operations = [ | |
| 13 | + migrations.RenameField( | |
| 14 | + model_name='log', | |
| 15 | + old_name='loc', | |
| 16 | + new_name='location', | |
| 17 | + ), | |
| 18 | + migrations.RemoveField( | |
| 19 | + model_name='log', | |
| 20 | + name='is_new', | |
| 21 | + ), | |
| 22 | + ] |
| @@ -0,0 +1,18 @@ | ||
| 1 | +# Generated by Django 5.0.6 on 2024-05-19 18:32 | |
| 2 | + | |
| 3 | +from django.db import migrations, models | |
| 4 | + | |
| 5 | + | |
| 6 | +class Migration(migrations.Migration): | |
| 7 | + | |
| 8 | + dependencies = [ | |
| 9 | + ('live_logger', '0006_rename_loc_log_location_remove_log_is_new'), | |
| 10 | + ] | |
| 11 | + | |
| 12 | + operations = [ | |
| 13 | + migrations.AddField( | |
| 14 | + model_name='log', | |
| 15 | + name='status_code', | |
| 16 | + field=models.IntegerField(null=True), | |
| 17 | + ), | |
| 18 | + ] |
No content changes (mode or rename only).
| @@ -0,0 +1,76 @@ | ||
| 1 | +from django.db import models | |
| 2 | +from . import settings | |
| 3 | +import requests | |
| 4 | + | |
| 5 | +# Create your models here. | |
| 6 | +class Location(models.Model): | |
| 7 | + ip = models.GenericIPAddressField(primary_key=True) | |
| 8 | + city = models.CharField(max_length=100, null=True) | |
| 9 | + region = models.CharField(max_length=100, null=True) | |
| 10 | + country = models.CharField(max_length=100, null=True) | |
| 11 | + loc = models.CharField(max_length=60, null=True) | |
| 12 | + org = models.CharField(max_length=100, null=True) | |
| 13 | + postal = models.CharField(max_length=20, null=True) | |
| 14 | + timezone = models.CharField(max_length=50, null=True) | |
| 15 | + bogon = models.BooleanField(default=False) | |
| 16 | + success = models.BooleanField(default=False) | |
| 17 | + | |
| 18 | + def download(self): | |
| 19 | + try: | |
| 20 | + data = requests.get(f'http://ipinfo.io/{self.ip}/json').json() | |
| 21 | + except: | |
| 22 | + return | |
| 23 | + self.success = True | |
| 24 | + self.city = data.get('city') | |
| 25 | + self.region = data.get('region') | |
| 26 | + self.country = data.get('country') | |
| 27 | + self.loc = data.get('loc') | |
| 28 | + self.org = data.get('org') | |
| 29 | + self.postal = data.get('postal') | |
| 30 | + self.timezone = data.get('timezone') | |
| 31 | + self.bogon = data.get('bogon') | |
| 32 | + return data | |
| 33 | + | |
| 34 | + def save(self, *args, **kwargs): | |
| 35 | + if settings.LIVE_LOGGER_DOWNLOAD_IPINFO and not self.success: | |
| 36 | + self.download() | |
| 37 | + super().save(*args, **kwargs) | |
| 38 | + | |
| 39 | + def __str__(self): | |
| 40 | + return self.ip | |
| 41 | + | |
| 42 | + | |
| 43 | +class Log(models.Model): | |
| 44 | + meta = models.JSONField() | |
| 45 | + messages = models.JSONField(default=list) | |
| 46 | + json = models.JSONField(default=dict) | |
| 47 | + start_time = models.DateTimeField() | |
| 48 | + end_time = models.DateTimeField() | |
| 49 | + location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True) | |
| 50 | + user = models.ForeignKey('auth.User', on_delete=models.SET_NULL, null=True) | |
| 51 | + status_code = models.IntegerField(null=True) | |
| 52 | + | |
| 53 | + def save(self, *args, **kwargs): | |
| 54 | + kwargs.pop('loc', None) | |
| 55 | + kwargs.pop('is_new', None) | |
| 56 | + meta = kwargs.pop('meta', self.meta).copy() | |
| 57 | + (loc, is_new) = Location.objects.update_or_create(ip=meta['REMOTE_ADDR'], defaults={ | |
| 58 | + 'ip': meta['REMOTE_ADDR'] | |
| 59 | + }) | |
| 60 | + for key, val in meta.items(): | |
| 61 | + meta[key] = str(val) | |
| 62 | + self.location = loc | |
| 63 | + self.is_new = is_new | |
| 64 | + self.meta = meta | |
| 65 | + overflow = Log.objects.count() - settings.LIVE_LOGGER_STORAGE_LENGTH | |
| 66 | + if overflow > 0: | |
| 67 | + ids_to_delete = Log.objects.all().order_by('id')[:overflow].values_list('id', flat=True) | |
| 68 | + Log.objects.filter(id__in=list(ids_to_delete)).delete() | |
| 69 | + super().save(*args, **kwargs) | |
| 70 | + | |
| 71 | + def __str__(self): | |
| 72 | + return self.meta['PATH_INFO'] | |
| 73 | + | |
| 74 | + def __call__(self, message): | |
| 75 | + self.messages += [message] | |
| 76 | + return self |
| @@ -0,0 +1,6 @@ | ||
| 1 | +from django.urls import path, re_path, include | |
| 2 | +from . import consumers | |
| 3 | + | |
| 4 | +websocket_urlpatterns = [ | |
| 5 | + path('ws/live_logger/logs/', consumers.LogConsumer.as_asgi()) | |
| 6 | +] |
| @@ -0,0 +1,21 @@ | ||
| 1 | +from rest_framework import serializers | |
| 2 | +from django.contrib.auth.models import User | |
| 3 | +from . import models | |
| 4 | + | |
| 5 | +class LocationSerializer(serializers.ModelSerializer): | |
| 6 | + class Meta: | |
| 7 | + model = models.Location | |
| 8 | + fields = '__all__' | |
| 9 | + | |
| 10 | +class UserSerializer(serializers.ModelSerializer): | |
| 11 | + class Meta: | |
| 12 | + model = User | |
| 13 | + fields = '__all__' | |
| 14 | + | |
| 15 | +class LogSerializer(serializers.ModelSerializer): | |
| 16 | + user = UserSerializer() | |
| 17 | + location = LocationSerializer() | |
| 18 | + | |
| 19 | + class Meta: | |
| 20 | + model = models.Log | |
| 21 | + fields = '__all__' |
| @@ -0,0 +1,9 @@ | ||
| 1 | +from django.conf import settings | |
| 2 | +import os | |
| 3 | + | |
| 4 | + | |
| 5 | +LIVE_LOGGER_STORAGE_LENGTH = getattr(settings, 'LIVE_LOGGER_STORAGE_LENGTH', os.getenv('LIVE_LOGGER_STORAGE_LENGTH', 1000)) | |
| 6 | +LIVE_LOGGER_PAGINATION = getattr(settings, 'LIVE_LOGGER_PAGINATION', os.getenv('LIVE_LOGGER_PAGINATION', 100)) | |
| 7 | +LIVE_LOGGER_DOWNLOAD_IPINFO = getattr(settings, 'LIVE_LOGGER_DOWNLOAD_IPINFO', os.getenv('LIVE_LOGGER_DOWNLOAD_IPINFO', True)) | |
| 8 | +LIVE_LOGGER_SHOW_MAP = getattr(settings, 'LIVE_LOGGER_SHOW_MAP', os.getenv('LIVE_LOGGER_SHOW_MAP', True)) | |
| 9 | +LIVE_LOGGER_IGNORED_PATHS = getattr(settings, 'LIVE_LOGGER_IGNORED_PATHS', os.getenv('LIVE_LOGGER_IGNORED_PATHS', ['static', 'favicon.ico', 'logs'])) |
| @@ -0,0 +1,158 @@ | ||
| 1 | +<!DOCTYPE html> | |
| 2 | +<html lang="en"> | |
| 3 | + <head> | |
| 4 | + <title>Title</title> | |
| 5 | + <!-- Required meta tags --> | |
| 6 | + <meta charset="utf-8" /> | |
| 7 | + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | |
| 8 | + | |
| 9 | + <!-- Bootstrap CSS v5.2.1 --> | |
| 10 | + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" /> | |
| 11 | + <style> | |
| 12 | + .code-block { | |
| 13 | + background-color: black; | |
| 14 | + color: #f8f8f2; /* light color for text */ | |
| 15 | + padding: 15px; | |
| 16 | + overflow-x: auto; /* add a scrollbar if the content is too wide */ | |
| 17 | + white-space: pre-wrap; /* wrap text */ | |
| 18 | + word-wrap: break-word; /* break words to prevent overflow */ | |
| 19 | + } | |
| 20 | + </style> | |
| 21 | + </head> | |
| 22 | + | |
| 23 | + <body> | |
| 24 | + <header> | |
| 25 | + <!-- Nav tabs --> | |
| 26 | + <ul class="nav nav-tabs" id="myTab" role="tablist"> | |
| 27 | + <a href="/" class="mx-1"><img src="/favicon.ico" width="40" height="40" class="img-fluid rounded-top my-auto" alt="Home" /></a> | |
| 28 | + <li class="nav-item" role="presentation"> | |
| 29 | + <button class="nav-link active" id="logs-tab" data-bs-toggle="tab" data-bs-target="#logs" type="button" role="tab" aria-controls="logs" aria-selected="true">Logs</button> | |
| 30 | + </li> | |
| 31 | + <li class="nav-item" role="presentation"> | |
| 32 | + <button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profile</button> | |
| 33 | + </li> | |
| 34 | + <li class="nav-item" role="presentation"> | |
| 35 | + <button class="nav-link" id="messages-tab" data-bs-toggle="tab" data-bs-target="#messages" type="button" role="tab" aria-controls="messages" aria-selected="false">Messages</button> | |
| 36 | + </li> | |
| 37 | + </ul> | |
| 38 | + | |
| 39 | + <!-- Tab panes --> | |
| 40 | + <div class="tab-content"> | |
| 41 | + <div class="tab-pane active" id="logs" role="tabpanel" aria-labelledby="logs-tab"></div> | |
| 42 | + <div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab">profile</div> | |
| 43 | + <div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab">messages</div> | |
| 44 | + </div> | |
| 45 | + </header> | |
| 46 | + <main></main> | |
| 47 | + <footer> | |
| 48 | + <!-- place footer here --> | |
| 49 | + </footer> | |
| 50 | + <!-- Bootstrap JavaScript Libraries --> | |
| 51 | + <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script> | |
| 52 | + | |
| 53 | + <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.min.js" integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+" crossorigin="anonymous"></script> | |
| 54 | + <script> | |
| 55 | + const ws = new WebSocket('/ws/live_logger/logs/') | |
| 56 | + const logDiv = document.getElementById('logs') | |
| 57 | + ws.onmessage = (event) => { | |
| 58 | + const message = JSON.parse(event.data) | |
| 59 | + if (message.type === 'logs') { | |
| 60 | + console.log(message.data[0]) | |
| 61 | + for (const log of message.data) { | |
| 62 | + const logDiv = document.getElementById('logs') | |
| 63 | + const user = log.user ? log.user.username : 'Anonymous' | |
| 64 | + let messages = '' | |
| 65 | + for (const message of log.messages) { | |
| 66 | + messages += message | |
| 67 | + } | |
| 68 | + logDiv.innerHTML += ` | |
| 69 | + <div class="accordion accordion-flush" id="log-${log.id}-accordian"> | |
| 70 | + <div class="accordion-item"> | |
| 71 | + <h2 class="accordion-header" id="log-${log.id}-header"> | |
| 72 | + <button | |
| 73 | + class="accordion-button collapsed" | |
| 74 | + type="button" | |
| 75 | + data-bs-toggle="collapse" | |
| 76 | + data-bs-target="#log-${log.id}-collapse" | |
| 77 | + aria-expanded="true" | |
| 78 | + aria-controls="log-${log.id}-collapse" | |
| 79 | + > | |
| 80 | + ${log.meta.REQUEST_METHOD} [${log.status_code}] ${log.meta.PATH_INFO} - ${log.meta.REMOTE_ADDR} - ${user} | |
| 81 | + </button> | |
| 82 | + </h2> | |
| 83 | + <div | |
| 84 | + id="log-${log.id}-collapse" | |
| 85 | + class="accordion-collapse collapse" | |
| 86 | + aria-labelledby="log-${log.id}-header" | |
| 87 | + data-bs-parent="#log-${log.id}-accordian" | |
| 88 | + > | |
| 89 | + | |
| 90 | + <!-- Log Messages --> | |
| 91 | + <div class="accordion-body"> | |
| 92 | + <div class="accordion accordion-flush" id="message-${log.id}-accordian"> | |
| 93 | + <div class="accordion-item"> | |
| 94 | + <h2 class="accordion-header" id="message-${log.id}-header"> | |
| 95 | + <button | |
| 96 | + class="accordion-button collapsed" | |
| 97 | + type="button" | |
| 98 | + data-bs-toggle="collapse" | |
| 99 | + data-bs-target="#message-${log.id}-collapse" | |
| 100 | + aria-expanded="true" | |
| 101 | + aria-controls="message-${log.id}-collapse" | |
| 102 | + > | |
| 103 | + Messages | |
| 104 | + </button> | |
| 105 | + </h2> | |
| 106 | + <div | |
| 107 | + id="message-${log.id}-collapse" | |
| 108 | + class="accordion-collapse collapse" | |
| 109 | + aria-labelledby="message-${log.id}-header" | |
| 110 | + data-bs-parent="#message-${log.id}-accordian" | |
| 111 | + > | |
| 112 | + <div class="accordion-body"> | |
| 113 | + <pre class="code-block"><code>${messages}</code></pre> | |
| 114 | + </div> | |
| 115 | + </div> | |
| 116 | + </div> | |
| 117 | + </div> | |
| 118 | + | |
| 119 | + <!-- Request Headers --> | |
| 120 | + <div class="accordion accordion-flush" id="meta-${log.id}-accordian"> | |
| 121 | + <div class="accordion-item"> | |
| 122 | + <h2 class="accordion-header" id="meta-${log.id}-header"> | |
| 123 | + <button | |
| 124 | + class="accordion-button collapsed" | |
| 125 | + type="button" | |
| 126 | + data-bs-toggle="collapse" | |
| 127 | + data-bs-target="#meta-${log.id}-collapse" | |
| 128 | + aria-expanded="true" | |
| 129 | + aria-controls="meta-${log.id}-collapse" | |
| 130 | + > | |
| 131 | + Request Headers | |
| 132 | + </button> | |
| 133 | + </h2> | |
| 134 | + <div | |
| 135 | + id="meta-${log.id}-collapse" | |
| 136 | + class="accordion-collapse collapse" | |
| 137 | + aria-labelledby="meta-${log.id}-header" | |
| 138 | + data-bs-parent="#meta-${log.id}-accordian" | |
| 139 | + > | |
| 140 | + <div class="accordion-body"> | |
| 141 | + <pre class="code-block"><code>${JSON.stringify(log.meta, null, 2)}</code></pre> | |
| 142 | + </div> | |
| 143 | + </div> | |
| 144 | + </div> | |
| 145 | + | |
| 146 | + <!-- Response Headers --> | |
| 147 | + </div> | |
| 148 | + </div> | |
| 149 | + </div> | |
| 150 | + </div> | |
| 151 | + </div> | |
| 152 | + ` | |
| 153 | + } | |
| 154 | + } | |
| 155 | + } | |
| 156 | + </script> | |
| 157 | + </body> | |
| 158 | +</html> |
| @@ -0,0 +1,3 @@ | ||
| 1 | +from django.test import TestCase | |
| 2 | + | |
| 3 | +# Create your tests here. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +from django.urls import re_path | |
| 2 | +from . import views | |
| 3 | + | |
| 4 | +urlpatterns = [ | |
| 5 | + re_path(r'logs/?$', views.logs, name='logs'), | |
| 6 | +] |
| @@ -0,0 +1,9 @@ | ||
| 1 | +import requests | |
| 2 | + | |
| 3 | + | |
| 4 | +def download_ipinfo(ip): | |
| 5 | + try: | |
| 6 | + data = requests.get(f'http://ipinfo.io/{ip}/json').json() | |
| 7 | + except: | |
| 8 | + return | |
| 9 | + return data |
| @@ -0,0 +1,8 @@ | ||
| 1 | +from django.shortcuts import render | |
| 2 | +from django.contrib.admin.views.decorators import staff_member_required | |
| 3 | + | |
| 4 | +# Create your views here. | |
| 5 | +@staff_member_required | |
| 6 | +def logs(request): | |
| 7 | + return render(request, 'live_logger/logs.html', { | |
| 8 | + }) |
| @@ -0,0 +1,22 @@ | ||
| 1 | +#!/usr/bin/env python | |
| 2 | +"""Django's command-line utility for administrative tasks.""" | |
| 3 | +import os | |
| 4 | +import sys | |
| 5 | + | |
| 6 | + | |
| 7 | +def main(): | |
| 8 | + """Run administrative tasks.""" | |
| 9 | + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') | |
| 10 | + try: | |
| 11 | + from django.core.management import execute_from_command_line | |
| 12 | + except ImportError as exc: | |
| 13 | + raise ImportError( | |
| 14 | + "Couldn't import Django. Are you sure it's installed and " | |
| 15 | + "available on your PYTHONPATH environment variable? Did you " | |
| 16 | + "forget to activate a virtual environment?" | |
| 17 | + ) from exc | |
| 18 | + execute_from_command_line(sys.argv) | |
| 19 | + | |
| 20 | + | |
| 21 | +if __name__ == '__main__': | |
| 22 | + main() |
| @@ -0,0 +1,10 @@ | ||
| 1 | +django | |
| 2 | +psycopg2-binary | |
| 3 | +watchdog | |
| 4 | +daphne | |
| 5 | +gunicorn | |
| 6 | +python-dotenv | |
| 7 | +requests | |
| 8 | +psutil | |
| 9 | +llama-index | |
| 10 | +django-vectordb[standard] |
No content changes (mode or rename only).
| @@ -0,0 +1,3 @@ | ||
| 1 | +from django.contrib import admin | |
| 2 | + | |
| 3 | +# Register your models here. |
| @@ -0,0 +1,6 @@ | ||
| 1 | +from django.apps import AppConfig | |
| 2 | + | |
| 3 | + | |
| 4 | +class SmartwatchConfig(AppConfig): | |
| 5 | + default_auto_field = 'django.db.models.BigAutoField' | |
| 6 | + name = 'smartwatch' |
| @@ -0,0 +1,13 @@ | ||
| 1 | +from django.core.management.base import BaseCommand | |
| 2 | +from django.core.management import call_command | |
| 3 | +from smartwatch.watch import watch_files, start_servers | |
| 4 | + | |
| 5 | +class Command(BaseCommand): | |
| 6 | + help = 'Starts the file watcher' | |
| 7 | + | |
| 8 | + def handle(self, *args, **options): | |
| 9 | + self.stdout.write('Starting file watcher...') | |
| 10 | + call_command('collectstatic', '--noinput') | |
| 11 | + call_command('migrate') | |
| 12 | + start_servers() | |
| 13 | + watch_files() |
No content changes (mode or rename only).
| @@ -0,0 +1,3 @@ | ||
| 1 | +from django.db import models | |
| 2 | + | |
| 3 | +# Create your models here. |
| @@ -0,0 +1,12 @@ | ||
| 1 | +from django.conf import settings | |
| 2 | + | |
| 3 | + | |
| 4 | +SMARTWATCH_GUNICORN_PORT = getattr(settings, 'SMARTWATCH_GUNICORN_PORT', 8000) | |
| 5 | +SMARTWATCH_GUNICORN_HOST = getattr(settings, 'SMARTWATCH_GUNICORN_HOST', '0.0.0.0') | |
| 6 | +SMARTWATCH_USE_GUNICORN = getattr(settings, 'SMARTWATCH_USE_GUNICORN', True) | |
| 7 | +SMARTWATCH_DAPHNE_PORT = getattr(settings, 'SMARTWATCH_DAPHNE_PORT', 8001) | |
| 8 | +SMARTWATCH_DAPHNE_HOST = getattr(settings, 'SMARTWATCH_DAPHNE_HOST', '0.0.0.0') | |
| 9 | +SMARTWATCH_USE_DAPHNE = getattr(settings, 'SMARTWATCH_USE_DAPHNE', True) | |
| 10 | + | |
| 11 | +SMARTWATCH_COLLECT_STATIC = getattr(settings, 'SMARTWATCH_COLLECT_STATIC', True) | |
| 12 | +SMARTWATCH_MIGRATE = getattr(settings, 'SMARTWATCH_MIGRATE', True) |
| @@ -0,0 +1,3 @@ | ||
| 1 | +from django.test import TestCase | |
| 2 | + | |
| 3 | +# Create your tests here. |
| @@ -0,0 +1,3 @@ | ||
| 1 | +from django.shortcuts import render | |
| 2 | + | |
| 3 | +# Create your views here. |
| @@ -0,0 +1,96 @@ | ||
| 1 | +import sys | |
| 2 | +import time | |
| 3 | +import psutil | |
| 4 | +import logging | |
| 5 | +from watchdog.observers import Observer | |
| 6 | +from watchdog.events import FileSystemEventHandler | |
| 7 | +from django.core.management import call_command | |
| 8 | +from django.contrib.staticfiles import finders | |
| 9 | +import os | |
| 10 | +from multiprocessing import Process | |
| 11 | +from . import settings | |
| 12 | + | |
| 13 | +def get_project_name(): | |
| 14 | + settings_module = os.getenv('DJANGO_SETTINGS_MODULE') | |
| 15 | + if settings_module is not None: | |
| 16 | + project_name = settings_module.split('.')[0] | |
| 17 | + return project_name | |
| 18 | + else: | |
| 19 | + return None | |
| 20 | + | |
| 21 | +def kill_gunicorn(): | |
| 22 | + for process in psutil.process_iter(): | |
| 23 | + if 'gunicorn' in process.name(): | |
| 24 | + process.kill() | |
| 25 | + | |
| 26 | +def start_gunicorn(hostname=None, port=None): | |
| 27 | + hostname = hostname or settings.SMARTWATCH_GUNICORN_HOST | |
| 28 | + port = port or settings.SMARTWATCH_GUNICORN_PORT | |
| 29 | + kill_gunicorn() | |
| 30 | + os.system(f'gunicorn -b {hostname}:{port} {get_project_name()}.wsgi:application') | |
| 31 | + | |
| 32 | + | |
| 33 | +def kill_daphne(): | |
| 34 | + for process in psutil.process_iter(): | |
| 35 | + if 'daphne' in process.name(): | |
| 36 | + process.kill() | |
| 37 | + | |
| 38 | + | |
| 39 | +def start_daphne(hostname=None, port=None): | |
| 40 | + hostname = hostname or settings.SMARTWATCH_DAPHNE_HOST | |
| 41 | + port = port or settings.SMARTWATCH_DAPHNE_PORT | |
| 42 | + kill_daphne() | |
| 43 | + os.system(f'daphne -b {hostname} -p {port} {get_project_name()}.asgi:application') | |
| 44 | + | |
| 45 | + | |
| 46 | +def start_servers(): | |
| 47 | + if settings.SMARTWATCH_USE_GUNICORN: | |
| 48 | + Process(target=start_gunicorn).start() | |
| 49 | + if settings.SMARTWATCH_USE_DAPHNE: | |
| 50 | + Process(target=start_daphne).start() | |
| 51 | + print('started the servers') | |
| 52 | + | |
| 53 | + | |
| 54 | +class ServerHandler(FileSystemEventHandler): | |
| 55 | + DEBOUNCE_SECONDS = 1 | |
| 56 | + | |
| 57 | + def __init__(self, *args, **kwargs): | |
| 58 | + super().__init__(*args, **kwargs) | |
| 59 | + self.last_modified = time.time() | |
| 60 | + | |
| 61 | + def on_modified(self, event): | |
| 62 | + current_time = time.time() | |
| 63 | + if current_time - self.last_modified < self.DEBOUNCE_SECONDS: | |
| 64 | + return | |
| 65 | + self.last_modified = current_time | |
| 66 | + | |
| 67 | + should_restart = event.src_path.endswith('.py') | |
| 68 | + if 'requirements.txt' in event.src_path: | |
| 69 | + logging.info(f'{event.src_path} has been modified. Installing requirements...') | |
| 70 | + should_restart = True | |
| 71 | + os.system('pip install -r requirements.txt') | |
| 72 | + if 'templates' in event.src_path: | |
| 73 | + should_restart = True | |
| 74 | + if settings.SMARTWATCH_MIGRATE and 'migrations' in event.src_path: | |
| 75 | + should_restart = False | |
| 76 | + logging.info(f'{event.src_path} has been modified. Running migrations...') | |
| 77 | + call_command('migrate') | |
| 78 | + if settings.SMARTWATCH_COLLECT_STATIC and 'static' in event.src_path: | |
| 79 | + logging.info(f'{event.src_path} has been modified. Collecting static files...') | |
| 80 | + call_command('collectstatic', '--noinput') | |
| 81 | + if should_restart: | |
| 82 | + logging.info(f'{event.src_path} has been modified. Restarting server...') | |
| 83 | + start_servers() | |
| 84 | + | |
| 85 | + | |
| 86 | +def watch_files(): | |
| 87 | + server_handler = ServerHandler() | |
| 88 | + observer = Observer() | |
| 89 | + observer.schedule(server_handler, '.', recursive=True) | |
| 90 | + observer.start() | |
| 91 | + try: | |
| 92 | + while observer.is_alive(): | |
| 93 | + observer.join(1) | |
| 94 | + finally: | |
| 95 | + observer.stop() | |
| 96 | + observer.join() |
Binary file changed.
| @@ -0,0 +1,24 @@ | ||
| 1 | +services: | |
| 2 | + postgres: | |
| 3 | + restart: always | |
| 4 | + image: postgres:alpine | |
| 5 | + env_file: | |
| 6 | + - .env | |
| 7 | + ports: | |
| 8 | + - "${POSTGRES_EXTERNAL_PORT}:5432" | |
| 9 | + volumes: | |
| 10 | + - .data/postgres:/var/lib/postgresql/data | |
| 11 | + app: | |
| 12 | + restart: always | |
| 13 | + build: app | |
| 14 | + env_file: | |
| 15 | + - .env | |
| 16 | + volumes: | |
| 17 | + - ./app:/app | |
| 18 | + nginx: | |
| 19 | + restart: always | |
| 20 | + image: nginx:alpine | |
| 21 | + ports: | |
| 22 | + - "${NGINX_EXPOSE_PORT}:80" | |
| 23 | + volumes: | |
| 24 | + - ./.nginx:/etc/nginx/conf.d |