Skip to content

Instantly share code, notes, and snippets.

@RobinDaugherty
Last active January 4, 2016 18:39
Show Gist options
  • Save RobinDaugherty/8661996 to your computer and use it in GitHub Desktop.
Save RobinDaugherty/8661996 to your computer and use it in GitHub Desktop.
Rails app on server
# To connect to the existing screen:
sudo screen -R -x
# - OR -
# If there wasn't already a screen running:
sudo screen -R
# This is a new screen, and you had to use root to start screen,
# so now change to the deploy user, setting up the correct environment.
sudo -u deploy -s -H
source /data/widget/shared/config/env.custom
cd /data/widget/current
# MRI:
bundle install
bundle exec rake assets:precompile
bundle exec puma -b tcp://0.0.0.0:5000 -e production -C config/puma.rb
# JRuby (because of an apparent rbenv bug):
/usr/local/rbenv/versions/jruby-1.7.8/bin/bundle install
/usr/local/rbenv/versions/jruby-1.7.8/bin/bundle exec rake assets:precompile
/usr/local/rbenv/versions/jruby-1.7.8/bin/bundle exec /usr/local/rbenv/versions/jruby-1.7.8/bin/puma -b tcp://0.0.0.0:5000 -e production -C config/puma.rb
# To get a new machine set up to run Rails:
# Increase the open-file-limit:
sudo cat > /etc/security/limits.d/openfile.conf <<EOD
root soft nofile 65535
root hard nofile 131070
* soft nofile 65535
* hard nofile 131070
EOD
sudo ulimit -Hn 131070
sudo ulimit -Sn 65535
adduser --ingroup users deploy
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update && sudo apt-get -y install nginx
sudo apt-get install nodejs
# MANUAL: Install rbenv using https://gist.github.com/RobinDaugherty/8669113
apt-get -y install default-jre-headless
rbenv install jruby-1.7.8
sudo chgrp users -R /usr/local/rbenv
sudo chmod g+w -R /usr/local/rbenv
sudo chmod g+s /usr/local/rbenv
sudo mkdir -p /data/widget/shared/{tmp,log,config}
sudo chown deploy -R /data
# MANUAL: Create /data/widget/shared/config/env.custom with a copy of the config from production.
sudo chown -R deploy /data
sudo -u deploy -H ssh-keygen
sudo -u deploy cat /home/deploy/.ssh/id_rsa.pub
# MANUAL: Add the new key as a deployment key to the github project.
sudo -u deploy git clone git@github.com:Ahalogy/widget.git /data/widget/current
sudo -u deploy rm -rf /data/widget/current/{log,tmp}
sudo -u deploy ln -s ../shared/log /data/widget/current/
sudo -u deploy ln -s ../shared/tmp /data/widget/current/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment