How to 'pre-bundle' a rails app - ruby-on-rails-4

I'm trying to bundle a rails app on an Ubuntu staging server, so that I can more or less just copy the whole thing to the production server.
Reason: I do not have privileges to install gems on production, being a managed server.
So, I ran bundle install
on the staging server
followed by scp -rC vendor/bundle user#production:~/app_dir/vendor/
Issues:
I'm not seeing the website after restarting the production webserver (apache/passenger) - instead I get "403 - You don't have permission to access / on this server.".
If I run for example rails c or rake assets:precompile I get "Could not find rake-10.4.2 in any of the sources" even though rake-10.4.2 exists in the vendor/bundle/ruby/2.0/gems folder
Is my approach of bundling and copying a sound one?
How do I make the rails app on production work with the gems from the vendor-folder?

Related

Unable to access rails console

I have deployed my application onto openshift and everything is working great until I tried to access the rails console.
ssh openshiftsshlogin
cd ~/app-root/repo/
rails c
When I run the above command I get this error.
bash: rails: command not found
My web application is open source which may help to diagnose the error.
Link to the Github repository.
Also when I run...
bundle exec rails c
I get the following error,
bundler: command not found: rails
Install missing gem executables with `bundle install`
/usr/lib/ruby/gems/1.8/gems/bundler-1.5.2/lib/bundler/friendly_errors.rb:10:in `with_friendly_errors': uninitialized constant Thor::AmbiguousTaskError (NameError)
from /usr/lib/ruby/gems/1.8/gems/bundler-1.5.2/bin/bundle:20
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19
I dont belive i need to manually install the rails gem as the gear is running a rails application just fine.
try RAILS_ENV=production bundle exec rails console
So weirdly enough I solved the issue by just running "gem install rails" even though I should not of needed to. So if a future person runs into this issue just run...
gem install rails
RAILS_ENV=production bundle exec rails console
That should solve the issue.

Upgrading Redmine from 3.0.7 to 3.2.0

I am trying to upgrade my Redmine 3.0.7 that was installed from the oneclick install to the newest stable version, 3.2.0. However, when I try to run svn update, it says it is updated, but doesn't show as updated in the info on the site. I tried to follow the information here:
You can checkout the latest stable source with one of the following commands:
Subversion
svn co https://svn.redmine.org/redmine/branches/3.2-stable redmine-3.2
It will create a directory named redmine-3.2 and you'll be able to update your Redmine copy using svn update in this directory.
The information from the info page on the admin section of my redmine:
Environment:
Redmine version 3.0.7.stable.15164
Ruby version 2.0.0-p643 (2015-02-25) [x86_64-linux]
Rails version 4.2.3
Environment production
Database adapter Mysql2
SCM:
Subversion 1.8.8
Filesystem
Redmine plugins:
no plugin installed
But it didn't work. Any help would be much appreciated.
In order to upgrade to a newer version of Redmine, specifically 3.2, you will need to switch to the 3.2-stable SVN branch and then perform the upgrade.
First off, I would recommend taking a snapshot of your Droplet so that you have a working state that you can restore in case anything goes wrong with the upgrade. If you can't power off your Droplet to take a snapshot, you can back up the files and settings manually. All uploaded files should be stored in /srv/redmine/files. The database can be backed up by running the following command:
mysqldump -u root redmine | gzip > ~/redmine_db_backup.sql.gz
Then, switch to the newer SVN branch:
cd /srv/redmine
svn switch ^/branches/3.2-stable
Make sure all the requires gems are installed and up-to-date:
bundle update
Next, you'll want to upgrade the database as well so that any changes in the database structure are applied to your existing database:
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
Finally, clear the cache and restart Passenger. This will log out all users.
bundle exec rake tmp:cache:clear tmp:sessions:clear RAILS_ENV=production
touch tmp/restart.txt
You might also want to check out the Admin -> Roles & permissions page for any new permissions.
Let me know if you have any issues. I've just tested it on a Droplet and everything went fine - so I'm hoping that everything will go smoothly for you as well.

How do I setup memcached for a django app on nitrous.io

I'm trying to setup a django app with memcached. I have the app working via virtualenv on nitrous.io without memcached.
I ran parts install memcached which worked fine. python-memcached is also installed in the virtualenv. I tried running:
memcached -d -m memory -s $HOME/memcached.sock -P $HOME/memcached.pid
which I do on my production server. But I got this error:
failed to set rlimit for open files. Try starting as root or requesting smaller maxconns value.
The user rights and whatnot are a little out of my scope of knowledge?
You should always use parts start memcached to run the service on Nitrous.IO.
To change the configuration for the memcached package, edit /home/action/.parts/etc/memcached.conf.

Django manage.py commands with Google App Engine and Vagrant

I have a Google App Engine app and I'm running Windows with Vagrant. I have an Ubuntu installation which I access via vagrant ssh. On that machine I installed the Google App Engine SDK for Python and I can successfully deploy my app with:
appcfg.py update myapp --oauth2 --noauth_local_webserver
The --noauth_local_parameter allows me to copy the oauth URL and paste in the browser on my Windows machine, because on the Linux machine I have no GUI. Everything is working fine.
But now I want to use the Django manage.py syncdb command, to create the tables in Google Cloud SQL. The problem is, when I execute that command, the text-based w3n browser starts for the authorization, and then I get the error message that the browser does not support javascript.
I'd like to run the manage.py commands with the --noauth_local_webserver flag, but that is not supported by the manage.py commands. How can I solve this? I have already installed an Ubuntu virtual machine with GUI and given the app the permission and manage.py works fine on that machine, but when I try to execute the command on the Vagrant (non GUI) machine, it stills want to open the browser for permission.
Hm, I manually copied the oauth .dat file to the vagrant server, and manage.py syncdb is now working, but the website still can't connect in the browser; it says:
No valid OAuth 2.0 credentials. Before using the Google SQL Service backend on dev_appserver, you must first run "manage.py syncdb" and proceed through the given instructions to fetch an OAuth 2.0 token.
It seems to be the same errors as here. In my case it seemed that the necessary GOOGLE_SQL_OAUTH2_REFRESH_TOKEN environment variable was not set. I copied this refresh token from the .dat file and set it in the app.yaml:
env_variables:
GOOGLE_SQL_OAUTH2_REFRESH_TOKEN: "..."
Now everything is working fine.

Spree Starting Server

I cloned the git repository onto a local machine and Amazon Web Services.
I've tried using script/server and rails s
The code is cloned using git://github.com/spree/spree.git
How do you start the server?
I'd rather use the full git so I can ultimately change the template.
Check out the section on the github page under "Working With Edge Source"
https://github.com/spree/spree
Clone the Git repo
git clone git://github.com/spree/spree.git
cd spree
Install the gem dependencies
bundle install
Create a sandbox Rails application for testing purposes (and automatically perform all necessary database setup)
bundle exec rake sandbox
Start the server
cd sandbox
rails server
I just checked it out and it works, but edge currently isn't working. You might just want to fork it and use your own fork as a gem for a standard spree-store set up.