Skip to content
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

Replace the app files atomically and docker stop first before starting up for succeeding commits #70

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5f0bf1f
replace files atomically
asakapab0i Jan 29, 2024
2cb4920
Merge pull request #1 from asakapab0i/bb-atomically-replace-the-app-f…
asakapab0i Jan 29, 2024
d96505f
create folder and ignore missing folder when deleting
asakapab0i Jan 29, 2024
7f82c7e
sudo
asakapab0i Jan 29, 2024
de9ea53
rename instead of mv
asakapab0i Jan 29, 2024
da9e3eb
fix symlink
asakapab0i Jan 29, 2024
b0a64ce
debug app path
asakapab0i Jan 29, 2024
558eb7a
restart when every succeeding commits
asakapab0i Jan 29, 2024
f524aca
comments and log messages
asakapab0i Jan 29, 2024
0a66a8b
delete the app folder it will be a symlink
asakapab0i Jan 29, 2024
ee817be
docker restart does not load the updates
asakapab0i Jan 29, 2024
2f73b20
remove default port in the url, it messes up csp policy
asakapab0i Jan 30, 2024
6c8400d
add lightsail dns zone support
asakapab0i Feb 4, 2024
e4ec549
uniform naming
asakapab0i Feb 5, 2024
391eadf
subdomain and create the subdomain early in the process
asakapab0i May 9, 2024
78556d2
before instantiation
asakapab0i May 9, 2024
fa3b99c
remove subdomain
asakapab0i May 9, 2024
1f38ae2
delete before terminating the instance
asakapab0i May 10, 2024
df863d7
debug info
asakapab0i May 10, 2024
eabb077
terminate instance requires a few more opts
asakapab0i May 10, 2024
e170a5e
terminate instance requires a few more opts
asakapab0i May 10, 2024
4b91b44
fix delete domain
asakapab0i May 10, 2024
becaa1f
add more parameter in down calss
asakapab0i May 10, 2024
d40340b
add more parameter in down calss
asakapab0i May 10, 2024
ca89df5
fix tags
asakapab0i May 10, 2024
b8197fd
call launch
asakapab0i May 10, 2024
1cfc063
restore target
asakapab0i May 10, 2024
4901e9b
Merge pull request #2 from asakapab0i/bb-add-dns-zone-support
asakapab0i May 10, 2024
dec8c84
add trycatch on create and delete domain
asakapab0i May 10, 2024
d74da51
generic error catch
asakapab0i May 10, 2024
75bdfd6
Merge pull request #3 from asakapab0i/bb-try-catch-create-delete-domain
asakapab0i May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions data/update_script.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ set +o allexport

cd /

sudo rm -rf "$APP_PATH"
sudo mkdir -p "$APP_PATH"
sudo chown -R ec2-user.ec2-user "$APP_PATH"
tar xzf "$1" -C "$APP_PATH"
# atomically replacing the app files
if file "$APP_PATH" | grep 'directory'; then
sudo rm -rf "$APP_PATH"
fi
sudo mkdir -p "${APP_PATH}_symlink_new" && sudo chown -R ec2-user.ec2-user "${APP_PATH}_symlink_new" && tar xzf "$1" -C "${APP_PATH}_symlink_new"
sudo ln -s "${APP_PATH}_symlink_new" "${APP_PATH}"
sudo rm -rf "${APP_PATH}_symlink_old" || true
sudo mv "${APP_PATH}_symlink_new" "${APP_PATH}_symlink_old"
sudo ln -vfns "${APP_PATH}_symlink_old" "${APP_PATH}"
sudo chown -R ec2-user.ec2-user "${APP_PATH}_symlink_old"

cd "$APP_PATH"

Expand All @@ -95,10 +101,13 @@ for i in {1..5}; do
if pull; then break ; fi
done

docker-compose up \
--wait \
--remove-orphans \
-d <%= locals.compose_options.join(" ") %>
if [ "$PULLPREVIEW_FIRST_RUN" = false ]; then
echo "Stopping the application..."
docker-compose stop
fi

echo "Starting up the application..."
docker-compose up --wait --remove-orphans -d <%= locals.compose_options.join(" ") %>

sleep 5

Expand Down
4 changes: 2 additions & 2 deletions lib/pull_preview/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def public_dns

def url
scheme = (default_port == "443" ? "https" : "http")
"#{scheme}://#{public_dns}:#{default_port}"
"#{scheme}://#{public_dns}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_port should be kept if different than a standard port, but yes can be removed if 443 or 80

end

def username
Expand Down Expand Up @@ -208,7 +208,7 @@ def ssh(command, input: nil)
end
end
[key_file_path].each{|file| FileUtils.chmod 0600, file}

cmd = "ssh #{"-v " if logger.level == Logger::DEBUG}-o ServerAliveInterval=15 -o IdentitiesOnly=yes -i #{key_file_path} #{ssh_address} #{ssh_options.join(" ")} '#{command}'"
if input && input.respond_to?(:path)
cmd = "cat #{input.path} | #{cmd}"
Expand Down