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

Use Mutagen pause/resume on stopped environments #141

Merged
merged 1 commit into from
Apr 15, 2020
Merged

Use Mutagen pause/resume on stopped environments #141

merged 1 commit into from
Apr 15, 2020

Conversation

fooman
Copy link
Contributor

@fooman fooman commented Apr 14, 2020

Mutagen is able to pause and resume sync sessions. I added pause/resume/monitor to the warden sync command. Additionally I changed the automatic Mutagen behaviour for the warden environment commands.

Now the following should happen:

  • warden env up -d when run for the first time should trigger warden sync start as before
  • warden env down should trigger warden sync stop as before
  • warden env stop should now trigger warden sync pause (you can check the status should say paused under warden sync list
  • warden env up -d when run for a previously stopped environment should trigger warden sync resume provided the underlying php-fpm container still has the same container id (you can check warden sync list should have the same synchronisation identifier) and we have a paused session

&& [[ $(warden sync list | grep -i 'Status: \[Paused\]' | wc -l | awk '{print $1}') == "1" ]] \
&& [[ $(warden env ps -q php-fpm) ]] \
&& [[ $(docker container inspect $(warden env ps -q php-fpm) --format '{{ .State.Status }}') = "running" ]] \
&& [[ $(warden env ps -q php-fpm) = $(warden sync list | grep -i 'URL: docker' | awk -F'/' '{print $3}') ]]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One thing I am unsure about is if we need to use = or ==. The existing implementation seems to use both and my bash knowledge is limited as to what to prefer here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The short version is = is the original equality operator, and at some point bash (and other shells) added == as an alias. They are both lexical string comparison operators when enclosed in [ ] but this changes when you enclose them in (( )) (arithmetic operator) where the two are no longer synonymous.

@davidalger
Copy link
Collaborator

This looks super neat. I'll run it through a few cycles on my macOS setup and see how it checks out.

@davidalger davidalger added the enhancement New feature or request label Apr 15, 2020
@fooman
Copy link
Contributor Author

fooman commented Apr 15, 2020

Good stuff - sorry the steps to confirm where off (warden down instead of warden env down and warden stop instead of warden env stop) but you probably already caught that.

@davidalger davidalger merged commit 930fde8 into wardenenv:develop Apr 15, 2020
@davidalger davidalger added this to the Warden 0.4.2 milestone Apr 15, 2020
@davidalger
Copy link
Collaborator

Amazing work. Tested out Ok, so I got it merged and included in the 0.4.2 release which I've just published. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants