README
InterShop
An incipient application foundation built on Postgres, with sprinkles of JavaScript and plPython3u
Table of Contents generated with DocToc
- Installation
- InterShop Commands
- InterShop AddOns
- The InterShop Dev Cycle
- No More FDWs FTW
- The MIRAGE File Mirror Module
- VNRs
- Invariants
- Catalog
- To Do
Installation
Dependencies
Postgres
- https://wiki.postgresql.org/wiki/Apt
- https://askubuntu.com/questions/445487/what-debian-version-are-the-different-ubuntu-versions-based-on
- https://www.linuxmint.com/download_all.php
sudo apt install wget ca-certificates psmisc
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt install postgresql-12
sudo apt install postgresql-server-dev-12
sudo apt install postgresql-plpython3-12
sudo apt install postgresql-contrib-12
sudo apt install postgresql-12-unit
sudo apt install postgresql-12-plsh
# sudo apt install postgresql-12-pgtap
# sudo apt install postgresql-12-pldebugger
# sudo apt install postgresql-9.6-plv8
# sudo apt install postgresql-plperl-9.6
Configure Postgres
Find Configuration File Locations
In the below, adjust port; the first Postgres installation will likely listen on port 5432, the next one on port 5433 and so on; this, of course, will vary depending on whether one installed a newer PG version along an older one and so.
sudo -u postgres psql --port 5433 -c " \
select \
name as key, \
setting as value, \
case setting when reset_val then '' else reset_val end as changed \
from pg_settings \
where true \
and ( category = 'File Locations' ) \
order by name;"
This will output a table similar to this one:
key | value | changed
-------------------+-----------------------------------------+---------
config_file | /etc/postgresql/12/main/postgresql.conf |
data_directory | /var/lib/postgresql/12/main |
external_pid_file | /var/run/postgresql/12-main.pid |
hba_file | /etc/postgresql/12/main/pg_hba.conf |
ident_file | /etc/postgresql/12/main/pg_ident.conf |
Personally, I prefer to create a git
-versioned project so I can track (and, when necessary, undo) my
changes to the PG configuration. Inside that project, I create one directory for each version and use
hardlinks (not symlinks) so I get mirrored local versions of the pertinent files that will always be
identical to the configurations as seen by Postgres.
In pg_hba.conf
, add these lines below the one that reads
# Database administrative login by Unix domain socket
local all postgres peer
Do not change the above, just add these lines to indicate that connections from localhost should always be trusted:
### in pg_hba.conf ###
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all localhost trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
You must restart Postgres after changing the configuration, for example with one of these lines:
sudo /etc/init.d/postgresql restart ; echo $?
sudo /etc/init.d/postgresql restart 12 ; echo $?
Statement-Level Statistics
In postgresql.conf
:
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
(must restart with sudo /etc/init.d/postgresql restart 12
or similar after change; note that errors
in this settings might not lead to visible error messages, but still prevent the server from restarting).
Otherwise, comment this out in 020-extensions.sql
:
create extension if not exists pg_stat_statements;
Also see here.
Python
sudo pip install pipenv
pipenv install tap.py pytest
cp ~/jzr/hengist/intershop.ptv .
ln -s ../intershop
intershop rebuild
pip3 install setuptools
pip3 install --user pipenv
pipenv install uharfbuzz
pipenv shell
intershop psql -f db/100-harfbuzz.sql
InterShop Initialization and (Re-) Building
mkdir myapp
cd myapp
wget https://raw.githubusercontent.com/loveencounterflow/intershop/master/copy-to-host-app/rakefile
wget https://raw.githubusercontent.com/loveencounterflow/intershop/master/copy-to-host-app/peru.yaml
wget https://raw.githubusercontent.com/loveencounterflow/intershop/master/intershop.ptv
If you don't already have a .gitignore
file, you may want to copy (or merge) the one from InterShop; this
is to make sure your git repo won't version a gazillion dependencies under node_modules
(although for some
use cases this is actually the recommended way):
wget https://raw.githubusercontent.com/loveencounterflow/intershop/master/.gitignore
You probably do not want to add the directories .peru
and intershop
to your git repo, so make sure
that both entries do appear in your .gitignore
file.
Edit intershop.ptv
so the line intershop/host/name
spells out the name of your app (let's call it
myapp
here), which will also become the name of the database and the Postgres user:
intershop/host/name ::text= myapp
intershop/db/port ::integer= 5432
intershop/db/name ::text= ${intershop/host/name}
intershop/db/user ::text= ${intershop/host/name}
You are now ready to start installation: peru sync
will pull the latest InterShop sources; rake intershop_npm_install
will run npm install
inside the newly established intershop
folder, and
intershop rebuild
will create a Postgres DB (named myapp
or whatever name you chose) and a user by the
same name and run all the *.sql
files in intershop/db
:
peru reup && peru sync rake intershop_npm_install
intershop rebuild
To get an idea what we have by now, take a gander at the catalog:
intershop psql -c "select * from CATALOG.catalog order by schema, name;"
The intershop psql
invocation is essentially nothing but psql -U $intershop_db_user -d $intershop_db_name -p $intershop_db_port ... "@