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 Ubuntu/Debian support #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

willian
Copy link

@willian willian commented Aug 2, 2013

I assume the users has Postgres and Redis on his machine.

@@ -119,7 +170,7 @@ fi
# Reset database and seed it
if [ -z "$KEEPDB" ]; then
echo "Reloading the database..."
append_log successfully bundle exec rake db:drop:all db:create:all db:migrate
append_log successfully bundle exec rake db:drop db:create db:migrate
Copy link
Member

Choose a reason for hiding this comment

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

Seems like I did drop:all and create:all here because the test db wouldn't get created w/o it.

Copy link
Author

Choose a reason for hiding this comment

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

Really? I have the test db without :all
With :all I received this messages:

This task only modifies local databases. swagexpert_development is on a remote host.
This task only modifies local databases. swagexpert_test is on a remote host.
This task only modifies local databases. swagexpert_staging is on a remote host.
This task only modifies local databases. swagexpert_production is on a remote host.

https://github.com/rails/rails/blob/master/activerecord/lib/active_record/tasks/database_tasks.rb#L197

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like you have your database remotely? Have you modified the database.yml or something?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I have.
I use two VM on vagrant, one for the Postgres and another one for the app. Here is my database.yml

development: &development
  adapter      : postgresql
  encoding     : unicode
  database     : swagexpert_development
  template     : template0
  pool         : 5
  min_messages : warning
  host         : <%= ENV['DATABASE_HOST'] %>

test: &test
  <<: *development
  database     : swagexpert_test

staging: &staging
  <<: *development
  database     : swagexpert_staging

production: &production
  <<: *development
  database     : swagexpert_production

The DATABASE_HOST variable has the IP of my db VM.

Copy link
Member

Choose a reason for hiding this comment

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

Why do you have a separate VM for your db?

Copy link
Member

Choose a reason for hiding this comment

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

We like to nuke the db with bin/setup though as it gets us all on the same playing field. We know it's not that data that's causing the problem on one machine vs another because they're all built from the same seed file. We like to reset our database several times daily.

Copy link
Author

Choose a reason for hiding this comment

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

Great! I didn't know that 😉
I'll use only one VM for the project

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good :)

Copy link
Author

Choose a reason for hiding this comment

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

I'll put :all back 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that DB_KEEP=1 will also allow you to do whatever you want with your db, since it will skip those commands.

@ericboehs
Copy link
Member

With some tweaks this will be fine. I need to test it on a ubuntu box as well. I'll try to get to that this weekend.

willian added 3 commits August 1, 2013 22:18
 * Always compile the latest ruby-lang.org's ruby version
 * Always download the latest phantomjs from Google Code
 * Install and configure Postgres for the current user
echo "Installing Ruby $LATEST_RUBY_VERSION"
quietly cd ruby-$LATEST_RUBY_VERSION && ./configure --silent --prefix=/usr/local/lib/ruby --bindir=/usr/local/bin && make --silent && sudo make install --silent && cd ..
quietly successfully rm -rf ruby-*
fi
Copy link
Author

Choose a reason for hiding this comment

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

@ericboehs, What you think about this approach?

Copy link
Member

Choose a reason for hiding this comment

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

Not bad.

The latest version of ruby 2.0 is available here: ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.0-stable.tar.gz .. but nice sed work ;) We could probably just assume if they have any version of ruby 2.0 it's good enough.

Line 98: Tick marks have been deprecated in favor of$()` (see). But that doesn't matter as 95-102 could be:

if $(ruby -e'p !!RUBY_VERSION[/^2.0/]'); then

As I mentioned in my previous comment, you could pipe wget's output directly to tar. So 106-108:

append_log successfully wget -qO- "ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.0-stable.tar.gz" | tar xzf -

Copy link
Author

Choose a reason for hiding this comment

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

I tried to put wget and tar on the same line as you said, but:

bzip2: Compressed file ends unexpectedly;
    perhaps it is corrupted?  *Possible* reason follows.
bzip2: Inappropriate ioctl for device
    Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

tar: Child returned status 2
tar: Error is not recoverable: exiting now
cp: cannot stat `phantomjs-*/bin/phantomjs': No such file or directory

Here is the line:

# $PJSURL = "https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2"
append_log successfully wget -qO - $PJSURL | tar xjpf -

Copy link
Member

Choose a reason for hiding this comment

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

Try dropping the p flag from tar. This works for me:

wget -qO - https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2 | tar xjf -

Copy link
Member

Choose a reason for hiding this comment

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

Hmm looks like the p flag just preserves permissions, so I'm not sure why that would fail.

Here's my full output:

wget -qO - https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2 | tar xjf - && ls -al phantomjs-* && rm -r phantomjs-*
total 56
drwxr-xr-x    8 ericboehs  staff    272 Jun  5 12:56 .
drwx------   43 ericboehs  staff   1462 Aug  2 22:37 ..
-rw-r--r--    1 ericboehs  staff  14945 Jun  5 12:56 ChangeLog
-rw-r--r--    1 ericboehs  staff   1429 Jun  5 12:56 LICENSE.BSD
-rw-r--r--    1 ericboehs  staff   3957 Jun  5 12:56 README.md
drwxr-xr-x    3 ericboehs  staff    102 Jun  5 12:56 bin
drwxr-xr-x  102 ericboehs  staff   3468 Jun  5 12:56 examples
-rw-r--r--    1 ericboehs  staff   1888 Jun  5 12:56 third-party.txt

Copy link
Author

Choose a reason for hiding this comment

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

I had to remove quietly successfully and now It works!

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

Successfully merging this pull request may close these issues.

3 participants