given a database named db:
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname='db'
AND state = 'idle in transaction'
[Unit] | |
Description=MongoDB Database Service | |
Wants=network.target | |
After=network.target | |
[Service] | |
Type=forking | |
PIDFile=/var/run/mongodb/mongod.pid | |
ExecStart=/usr/local/bin/mongod --config /etc/mongod.conf | |
ExecReload=/bin/kill -HUP $MAINPID |
THIS STRING IS 256 CHARACTERS xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
given a database named db:
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname='db'
AND state = 'idle in transaction'
# update packages | |
sudo apt-get update | |
# install python and graphite dependencies | |
sudo apt-get install -y python python-dev python-virtualenv libevent-dev python-pip python-cairo python-django-tagging python-twisted python-memcache python-pysqlite2 | |
# install web server | |
sudo apt-get install -y nginx uwsgi uwsgi-plugin-python | |
# install postgresql and dependencies |
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key | |
# Don't add passphrase | |
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub | |
cat jwtRS256.key | |
cat jwtRS256.key.pub |
This sets up a publically-available domain that loops back to localhost IP address 127.0.0.1
. For example, this address could be localhost.example.com
if we controlled the example.com
domain. This relies on having a public domain name whose DNS records you can control. We can then generate LetsEncrypt certificates for this domain.
Our HTTP server runs on localhost:80
(default HTTP port). This lets us visit http://localhost.example.com
in a web browser and see the server running on localhost:80
.
We then run an HTTPS proxy server on localhost:443
(default HTTPS port) that uses the LetsEncrypt certificates we generated for localhost.example.com
. Visiting https://localhost.example.com
hits the proxy, which returns the correct certificates meaning the browser displays the "Secure" message. The proxy then passes the request through to the HTTP server.