Skip to content

Commit

Permalink
Merge origin into local
Browse files Browse the repository at this point in the history
  • Loading branch information
BanjoFox committed Aug 21, 2023
2 parents 25a6450 + ccd87b5 commit 133c2f4
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 47 deletions.
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

File renamed without changes.
6 changes: 6 additions & 0 deletions Docker/Dockerfile.actix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM rust:bookworm-slim

RUN apt-get --yes update && apt-get --yes install curl git pkg-config libssl-dev
RUN cargo install cargo-watch
RUN rustup component add clippy-preview
RUN rustup component add rustfmt
5 changes: 5 additions & 0 deletions Docker/Dockerfile.postgresql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM postgres:latest

RUN psql -c "CREATE DATABASE aardwolf;"
RUN psql -c "CREATE USER aardwolf WITH PASSWORD 'p4ssw0rd'"
RUN psql -c "GRANT ALL PRIVILEGES ON DATABASE aardwolf TO aardwolf;"
8 changes: 8 additions & 0 deletions Docker/Dockerfile.yew
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM rust:bookworm-slim

RUN apt-get --yes update && apt-get --yes install git pkg-config libssl-dev
RUN cargo install wasm-bindgen-cli
RUN cargo install trunk
RUN rustup target add wasm32-unknown-unknown
RUN rustup component add clippy-preview
RUN rustup component add rustfmt
File renamed without changes.
File renamed without changes.
45 changes: 25 additions & 20 deletions doc/SETUP-POSTGRES-15_WIP.MD → doc/SETUP-POSTGRES-15_WIP.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Ensure that lsb-release and wget are installed
### Ensure that lsb-release and wget are installed
sudo apt-get install lsb-release wget

# Create the file repository configuration:
### Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Import the repository signing key:
### Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

# Update the package lists:
### Update the package lists:
sudo apt-get update

# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
### Install the latest version of PostgreSQL.
### If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql libpq libpq-dev

Switch to the postgresql command line
Expand All @@ -20,15 +20,15 @@ Switch to the postgresql command line

Create a superadmin role

postgres=# CREATE ROLE admin WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'Passw0rd';
postgres=# CREATE ROLE admin WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'Passw0rd';

Create the database for Aardwolf

postgres=# CREATE DATABASE aardwolf;
postgres=# CREATE DATABASE aardwolf;

Create the DB user

postgres=# CREATE USER aardwolf WITH PASSWORD 'p4ssw0rd';
postgres=# CREATE USER aardwolf WITH PASSWORD 'p4ssw0rd';

Give `aardwolf user` all permissions to the `aardwolf-db` itself.

Expand All @@ -37,32 +37,37 @@ Give `aardwolf user` all permissions to the `aardwolf-db` itself.
Exit the postgresql command line
\q

# Good to know commands (Upgrading cluster versions)
### Good to know commands (Upgrading cluster versions)

Be sure you are still running on the old 14 cluster, Then backup your data with
`pg_dumpall -F t > ~/backup_postgres_all_dbs.tar`

pg_dumpall -F t > ~/backup_postgres_all_dbs.tar
Stop the still empty default installed postgreSQL 15 cluster and drop it.
`pg_dropcluster 15 main --stop`

pg_dropcluster 15 main --stop
Upgrade the 14 cluster to the latest version (which is 15 at the moment writing)
`pg_upgradecluster 14 main`

pg_upgradecluster 14 main
This can take some hours. Once it is finished, check that the upgraded cluster works:

```
service postgresql@14-main stop
service postgresql@15-main start
Your 14 cluster should now be “down”. you can verify it running:
```

pg_lsclusters
Your 14 cluster should now be “down”. you can verify it by running:`pg_lsclusters`

**Output:**
```
Ver Cluster Port Status Owner Data directory Log file
14 main 5433 down postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
15 main 5432 online postgres /var/lib/postgresql/15/main /var/log/postgresql/postgresql-15-main.log
```

Check if the applications, that use postgreSQL all work (eventually adapt the port in your psql-15 config). If everything is fin then remove the 14 cluster with

# !be really sure to call this!
# !DON'T BE TOO FAST!!! # pg_dropcluster 14 main
and remove the old packages.
### !be really sure to call this! ### !DON'T BE TOO FAST!!! ###
**This command will DROP YOUR VERSION 14 CLUSTER!** <br />
`pg_dropcluster 14 main`

apt-get purge postgresql-14 postgresql-client-14
**Finally, remove the old packages**<br />
`apt-get purge postgresql-14 postgresql-client-14`
30 changes: 8 additions & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,30 @@ pub fn configure(parsed_args: Args) -> Result<Config> {
.context(ErrorKind::ConfigImmutable)?;

// Determine config file
let config_file = env::var("AARDWOLF_CONFIG").unwrap();
let config_path = parsed_args.config.unwrap();
let config_file = config_path.to_str().unwrap();

builder = builder
.set_override("cfg_file", config_file.clone())
.set_override("cfg_file", config_file)
.context(ErrorKind::ConfigImmutable)?;

builder = builder.add_source(File::new(&config_file, FileFormat::Json)); // Or whatever format
builder = builder.add_source(File::new(config_file, FileFormat::Toml)); // Or whatever format

let config_path = parsed_args.config.unwrap();
builder = builder
.set_override("cfg_file", config_path.to_str())
.set_override("cfg_file", config_file)
.context(ErrorKind::ConfigImmutable)?;
//}

// Apply environmenet variable overrides
let env_vars = Environment::with_prefix("AARDWOLF")
.separator("_")
.ignore_empty(true);
builder = builder.add_source(env_vars);
//

let log_path = parsed_args.log.unwrap();
builder = builder
.set_override("Log.file", log_path.to_str())
.context(ErrorKind::ConfigImmutable)?;

//Err(ErrorKind::ConfigImmutable.into())

match builder.build() {
Ok(config) => {
env::set_var("DATABASE_URL", db_conn_string(&config)?);
Expand All @@ -70,18 +68,6 @@ pub fn configure(parsed_args: Args) -> Result<Config> {
return Err(e.into());
}
}

// Merge config file and apply overrides
//let config_file_string = config
// .get_string("cfg_file")
// .context(ErrorKind::ConfigMissingKeys)?;
//let config_file = config::File::with_name(&config_file_string);
//config.merge(config_file).context(ErrorKind::ConfigImmutable)?;

// Apply environment variable overrides

// Remove the need for a .env file to avoid defining env vars twice.

}

pub fn db_conn_string(config: &Config) -> Result<String> {
Expand Down Expand Up @@ -149,4 +135,4 @@ pub fn begin_log(config: &config::Config) {
#[cfg(feature = "systemd")]
pub fn begin_log(config: &config::Config) {
// TODO: Implement use-systemd:begin_log()
}
}

0 comments on commit 133c2f4

Please sign in to comment.