-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add local dev setup script #1237
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ac47301
Add local dev script
zivkovicmilos d52352c
Merge branch 'master' into feat/add-local-script
zivkovicmilos 6858642
Merge branch 'master' into feat/add-local-script
zivkovicmilos fe01215
Modify local loop script
zivkovicmilos f7a86d8
Change module name for loop
zivkovicmilos 519db1f
Change makefile recipe name
zivkovicmilos 861463e
Update misc/loop/Makefile
zivkovicmilos d3ba529
Add comment to loop script
zivkovicmilos 33b86d0
Simplify teardown
zivkovicmilos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.PHONY: all local | ||
|
||
all: local | ||
|
||
local: | ||
echo "Giving permissions to run script" | ||
chmod u+x ./dev.sh | ||
echo "Running local development setup" | ||
@./dev.sh $$RESTORE_DIR $$BACKUP_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Constants and Configurations | ||
TX_ARCHIVE_BINARY="github.com/gnolang/tx-archive/cmd@latest" | ||
DELAY=5 | ||
|
||
# The restore source directory | ||
restore_dir=$1 | ||
|
||
# The backup output directory | ||
backup_dir=$2 | ||
|
||
# Set up the kill signal callback | ||
teardown() { | ||
echo "Stopping background processes..." | ||
kill 0 | ||
} | ||
|
||
# Set up the required tx-archive tool | ||
install_tools() { | ||
echo "Installing tx-archive binary" | ||
if go install $TX_ARCHIVE_BINARY; then | ||
echo "Installation successful" | ||
else | ||
echo "Failed to install the binary" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Helper for checking the local exit code | ||
check_exit_code() { | ||
local exit_code=$? | ||
if [ $exit_code -ne 0 ]; then | ||
echo "Error: Process failed with exit code $exit_code" | ||
teardown | ||
fi | ||
} | ||
|
||
# Install the required tools | ||
install_tools | ||
|
||
# Pull in the latest changes from VC | ||
cd ../.. | ||
git checkout master | ||
git pull | ||
|
||
# Clean out the blockchain data | ||
cd gno.land && make clean fclean build install | ||
|
||
# Start the gnoland node (fresh chain), and in parallel | ||
# - start the restore service for transactions | ||
# - start the backup service for transactions | ||
( | ||
echo "Starting Gno node..." | ||
gnoland start | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note for later: add the |
||
check_exit_code | ||
) & | ||
( | ||
# Sleep the restore until the node is fully loaded up | ||
sleep $DELAY | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
echo "Starting restore..." | ||
cmd restore -legacy -watch -input-path "$restore_dir" | ||
check_exit_code | ||
) & | ||
( | ||
# Sleep the restore until the node is fully loaded up | ||
sleep $DELAY | ||
echo "Starting backup..." | ||
cmd backup -legacy -watch -overwrite -output-path "$backup_dir" | ||
check_exit_code | ||
) & | ||
|
||
# Trap all kill signals | ||
trap 'teardown' INT | ||
|
||
# Wait for all background processes to finish | ||
wait |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for later: add a
--watch
option to automatically reload based on FS changes.