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

Add locking / Handle corrupt hosts-localdev #3

Open
ChrisHardie opened this issue Jan 18, 2016 · 1 comment
Open

Add locking / Handle corrupt hosts-localdev #3

ChrisHardie opened this issue Jan 18, 2016 · 1 comment

Comments

@ChrisHardie
Copy link

Somehow my /etc/hosts-localdev file became populated in a way that led to errors with list/add/remove operations. It looked like:


---
- domain: domain.com
  ip: 195.5.83.200
195.5.83.200

Then I'd get:

$ localdev list
/Library/Ruby/Gems/2.0.0/gems/psych-2.0.17/lib/psych.rb:376:in `parse': (<unknown>): could not find expected ':' while scanning a simple key at line 4 column 1 (Psych::SyntaxError)
    from /Library/Ruby/Gems/2.0.0/gems/psych-2.0.17/lib/psych.rb:376:in `parse_stream'
    from /Library/Ruby/Gems/2.0.0/gems/psych-2.0.17/lib/psych.rb:324:in `parse'
    from /Library/Ruby/Gems/2.0.0/gems/psych-2.0.17/lib/psych.rb:251:in `load'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/lib/localdev.rb:202:in `block in list'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/lib/localdev.rb:201:in `open'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/lib/localdev.rb:201:in `list'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/lib/localdev.rb:43:in `initialize'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/bin/localdev:22:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/bin/localdev:22:in `<top (required)>'
    from /usr/local/bin/localdev:23:in `load'
    from /usr/local/bin/localdev:23:in `<main>'

Emptying the hosts-localdev file fixed this. It would be great to have some kind of integrity check on the file, or at least a better error message.

@ChrisHardie
Copy link
Author

I think I've traced this issue to a script I'm using that runs localdev twice at the same time. I suspect that without any kind of locking mechanism, the writes to /etc/hosts-localdev are colliding. I can look at adding locking to prevent this, any suggestions about where to start are welcome.

@ChrisHardie ChrisHardie changed the title Handle corrupt hosts-localdev Add locking / Handle corrupt hosts-localdev Nov 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant