nix: Do not start PG if running In a nix hook the PG server is started when `nix-shell` is invoked. This created extra output when nix-shell was invoked on an extra shell as it tried to start a new PG server again while it was already running. This change updates the behaviour to not do this, and verify with pg_ctl if PG is already running.

zj
Aug 9, 2021, 1:00 PM
BAWJ3BJ5X7JY7BFSEO2PLC4ZYIQ7WLAWKCVHIW4EP2DZLBDA2K2AC

Dependencies

  • [2] EIIUUAKG nix: Install and initialize a Postgres DB For a persistance layer, this change introduces postgresql as dependency. The daemon is started when `nix-shell` is invoked. `pg_ctl stop` is not invoked, and this has to be done by a developer. Data is persisted in a tmp directory, which is added to the ignore file.
  • [3] K4JNAJOF database: Connect to postgres on Rocket boot As database I've chosen PostgreSQL, as my personal experience has been good with it. This change allows Rocket to connect to the database on booting the server. It depends on the DATABASE_URL being set, and for now circumvents the Rocket config helpers as it seemed faster to be up and running this way.
  • [4] W3M3C7CC Initial commit This change includes a very small hello world application server written in Rust using Rocket.rs. Managing dependencies is done with Nix as that works well between Linux and Mac for me.

Change contents

  • replacement in shell.nix at line 36
    [2.480][2.480:571]()
    pg_ctl start -l $LOG_PATH -o "-c listen_addresses= -c unix_socket_directories=$PGHOST"
    [2.480]
    [2.571]
    if ! pg_ctl status &>2; then
    pg_ctl start -l $LOG_PATH -o "-c listen_addresses= -c unix_socket_directories=$PGHOST"
    fi
  • edit in README.md at line 13
    [3.1366]
    [3.1366]
    When `nix-shell` is in your `$PATH`, execute: `nix-shell`. Nix will download and
    manage dependencies for you. Nix will also start a postgresql server and initiate
    the database.
  • edit in README.md at line 18
    [3.1367]
    [3.1367]
    To start the server run: `cargo run`.