I have set up a RoR environement on AWS' elastic beanstalk. I am able to ssh into my EC2 instance. My home directory is /home/ec2-user, which is effectively empty. If I move up a directory, there is also a /home/webapp directory that i do not have access to.
Is there a way to run a rake command or rails console on my elastic beanstalk instance?
If I type rails console I get Usage: rails new APP_PATH [options]
If I type RAILS_ENV=production bundle exec rails console, I get "Could not locate Gemfile
"
I like to create an
eb_console
file at the root of my rails app, thenchmod u+x
it. It contains the following:This way, I just have to run:
like I would have run
heroku run bundle exec rails c
.You have to find the folder with your Gemfile :p.
To do that, I would take a look in you web server config there should be a config that tells you where your app directory is.
Maybe you know where your app is.
But in case you don't know, I would give a try to:
To search files containing your_app_name in Apache config.
Or if you are using nginx, replace
apache
above bynginx
.after you find application folder, cd into it and run
RAILS_ENV=production bundle exec rails c
.Making sure that your application is configured to run in production in Apache or nginx configuration.
Don't know why, but since EBS runs everything as root, this worked for me:
None of these were working for me, including the aws-console script. I finally ended up creating a
script
directory in/var/app/current
and then creating arails
file in that directory as outline by this answer on another SO question.Add this to file and save:
Then make it executable and run it:
And it worked.
For rails, jump to
/var/app/current
then as @juanpastas said, runRAILS_ENV=production bundle exec rails c
None of the other answers worked for me so I went looking - this is working for me now on an elastic beanstalk 64bit amazon linux 2016.03 V2.1.2 ruby 2.2 (puma) stack
that returns me the expected console