Skip to content

Commit

Permalink
fix debug printing config on start, add a sync_to_host script
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciechsromek committed Jul 9, 2024
1 parent d88f13a commit 0e7d04e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
42 changes: 42 additions & 0 deletions scripts/sync_to_hosts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

# Define the target directory
USER_NAME="wojciech-sromek"
TARGET_DIR="/home/ubuntu/${USER_NAME}"

# Define the hosts, order is important, indices are used to identify .env files
TARGET_HOSTS=(
"[email protected]"
"[email protected]"
"[email protected]"
)

# Define the directories to exclude
EXCLUDE_DIRS=(".idea" ".git" "target")

# Create the exclude options for rsync
EXCLUDE_OPTIONS=()
for EXCLUDE_DIR in "${EXCLUDE_DIRS[@]}"; do
EXCLUDE_OPTIONS+=("--exclude=$EXCLUDE_DIR")
done

# Get the name of the current working directory
CURRENT_DIR_NAME=$(basename "$PWD")

## Loop through each host using an index, starting with 1
for i in "${!TARGET_HOSTS[@]}"; do
INDEX=$((i + 1))
HOST=${TARGET_HOSTS[$i]}
echo "Syncing $CURRENT_DIR_NAME to $HOST:$TARGET_DIR (Target Host $INDEX)"

## Make sure that the correct environment file is copied to the correct host
cp .env.mpc$INDEX.dist .env

## Sync the current directory to the target host
rsync -avz --delete "${EXCLUDE_OPTIONS[@]}" "$PWD" "$HOST:$TARGET_DIR"
if [ $? -eq 0 ]; then
echo "Sync to $HOST completed successfully."
else
echo "Sync to $HOST failed."
fi
done
3 changes: 2 additions & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ impl Config {

let config: Config = settings.try_deserialize::<Config>()?;

dbg!("Debug config: {config:?}");
dbg!("Debug config");
dbg!(&config);

Ok(config)
}
Expand Down

0 comments on commit 0e7d04e

Please sign in to comment.