From 705ac0fba2dc879115509006ce4fdfae8c9fc5c0 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 15 Mar 2019 15:39:59 -0700 Subject: update dev setup instructions --- rust/INSTALL.md | 7 +++---- rust/README.md | 32 +++++++++++++++++++++----------- rust/env.example | 10 ---------- rust/example.env | 10 ++++++++++ 4 files changed, 34 insertions(+), 25 deletions(-) delete mode 100644 rust/env.example create mode 100644 rust/example.env (limited to 'rust') diff --git a/rust/INSTALL.md b/rust/INSTALL.md index 7b7d6001..462072dc 100644 --- a/rust/INSTALL.md +++ b/rust/INSTALL.md @@ -2,12 +2,12 @@ Canonical IA production/QA ansible scripts are in the journal-infra repo. These directions are likely to end up out-of-date. -## Simple Deployment +## Simple Server Deployment To install manually, on a bare server, as root: adduser fatcat - apt install postgresql-9.6 postgresql-contrib postgresql-client-9.6 \ + apt install postgresql-11 postgresql-contrib postgresql-client-11 \ nginx build-essential git pkg-config libssl-dev libpq-dev \ htop screen mkdir -p /srv/fatcat @@ -16,7 +16,6 @@ To install manually, on a bare server, as root: # setup new postgres user su - postgres createuser -P -s fatcat # strong random password - # DELETE: createdb fatcat # as fatcat user su - fatcat @@ -25,7 +24,7 @@ To install manually, on a bare server, as root: source $HOME/.cargo/env cargo install diesel_cli --no-default-features --features "postgres" cd /srv/fatcat - git clone git@git.archive.org:webgroup/fatcat + git clone https://github.com/internetarchive/fatcat.git cd rust cargo build echo "DATABASE_URL=postgres://fatcat@localhost/fatcat" > .env diff --git a/rust/README.md b/rust/README.md index 7393322d..e191d03e 100644 --- a/rust/README.md +++ b/rust/README.md @@ -21,26 +21,36 @@ do development work: - rust stable, 2018 edition, 1.32+ (eg, via "rustup", includes cargo tool) - diesel (`cargo install diesel_cli`) - postgres (compatible with 9.6+; run 11.x in production) -- postgres libs (debian: `sudo apt install libsqlite3-dev libpq-dev`) -- libsodium library and development headers (debian: `libsodium-dev`) +- postgres libs (debian/ubuntu: `libsqlite3-dev libpq-dev`) +- libsodium library and development headers (debian/ubuntu: `libsodium-dev`) -Copying commands out of `../.gitlab-ci.yml` file may be the fastest way to get -started. +We need to create a new `fatcat` postgres user and database to run tests and +develop with. On debian/ubuntu, a UNIX account named `postgres` is +automatically created with control over the database, so we'll run setup +commands from that user. To create the database account: -Create a new postgres superuser. A regular postgres user and an existing -database should also work (with up/down migrations), but it's easier to just -blow the entire database away. + sudo su - postgres -Copy `env.example` to `.env`, update if needed, then re-create database from -scratch: + # this command creates a PostgreSQL user, not a UNIX/system user + createuser -s fatcat -P + + # switch back to your regular system user + exit + +Copy `./example.env` to `./.env` and update the `DATABASE_URL` and +`TEST_DATABASE_URL` lines with the password you set above. + +As your regular user, use `diesel` to create and initialize the `fatcat` +database (`diesel` and the fatcat tools will automatically use postgresql +credentials from the `.env` file): diesel database reset -Build and run: +Build and run the API server: cargo run --bin fatcatd -Tests: +Run tests: cargo test -- --test-threads 1 diff --git a/rust/env.example b/rust/env.example deleted file mode 100644 index bee653c2..00000000 --- a/rust/env.example +++ /dev/null @@ -1,10 +0,0 @@ -DATABASE_URL="postgres://fatcat:tactaf@localhost/fatcat" -TEST_DATABASE_URL="postgres://fatcat:tactaf@localhost/fatcat_test" -AUTH_LOCATION="dev.fatcat.wiki" -AUTH_KEY_IDENT="20190101-dev-dummy-key" -AUTH_SECRET_KEY="5555555555555555555555555555555555555555xms=" -AUTH_ALT_KEYS="20181220-dev:6666666666666666666666666666666666666666xms=,20181210-dev:7777777777777777777777777777777777777777xms=" -#SENTRY_DSN= -# should be localhost IP, not 'localhost' -#FATCAT_STATSD_HOST="127.0.0.1" -#FATCAT_STATSD_PORT="8125" diff --git a/rust/example.env b/rust/example.env new file mode 100644 index 00000000..bee653c2 --- /dev/null +++ b/rust/example.env @@ -0,0 +1,10 @@ +DATABASE_URL="postgres://fatcat:tactaf@localhost/fatcat" +TEST_DATABASE_URL="postgres://fatcat:tactaf@localhost/fatcat_test" +AUTH_LOCATION="dev.fatcat.wiki" +AUTH_KEY_IDENT="20190101-dev-dummy-key" +AUTH_SECRET_KEY="5555555555555555555555555555555555555555xms=" +AUTH_ALT_KEYS="20181220-dev:6666666666666666666666666666666666666666xms=,20181210-dev:7777777777777777777777777777777777777777xms=" +#SENTRY_DSN= +# should be localhost IP, not 'localhost' +#FATCAT_STATSD_HOST="127.0.0.1" +#FATCAT_STATSD_PORT="8125" -- cgit v1.2.3