Ask A Question

Notifications

You’re not receiving notifications from this thread.

Deploy Ubuntu 20.04 Focal Fossa Discussion

Chris Oliver asked in General

Hello i have a small question.
you have connect a pg db with this command 'psql -U deploy -W -h 127.0.0.1 -d myapp'
but how to connect a mysql db ..???

Reply

Hi Crish, I would like to deploy two apps in one server with capistrano and passenger. But after I run cap production deploy, I got this error:

DEBUG [c7975899] *** Cleaning stale instance directory /tmp/passenger.rV0FH1J
Warning: Operation not permitted @ rb_file_chown - /tmp/passenger.rV0FH1J/.
*** Cleaning stale instance directory /tmp/passenger.tAi6t3K
Warning: Operation not permitted @ rb_file_chown - /tmp/passenger.tAi6t3K/.
It appears that multiple Phusion Passenger(R) instances are running. Please select
a specific one by passing:

--instance

The following Phusion Passenger(R) instances are running:

Name PID Description

dBWxWYef 5377 nginx/1.18.0 Phusion_Passenger/6.0.11
BeV0It9m 2635 nginx/1.18.0 Phusion_Passenger/6.0.11

How to solve this problem?
Thanks Chris

Reply

First off all - thx for this (and many other) tutorials. I have been working with Rails for many years and deployment has always been a black box for me. The kind of task... for someone else.

But spoiler alert - my droplet is running smoothly with 3.0.2 und 7.0.0.rc1

In case someone else has problems with passwords when accessing the database (in my case mysql) - check for '$' in your password.

nano /home/deploy/myapp/.rbenv-vars
DATABASE_URL=mysql2://deploy:$omeFancyPassword123@localhost/myapp
DATABASE_PASSWORD_1=$omeFancyPassword123
DATABASE_PASSWORD_2=SomeFancy$Password123

rails c ENV
"DATABASE_URL"=>"mysql2://deploy:@localhost/myapp",
"DATABASE_PASSWORD_1"=>"",
"DATABASE_PASSWORD_2"=>"SomeFancy",

It took me a while to get to grips with the concept of production. I just started rails commands too often without the enviroment. But fun-fact: In the new rails 7 the gem 'debug' is used in the group development. And this was 'buggy' in my setup. So this was nice (after i googled the error... inspected the gem... ;)

Happy greetings from Hamburg
Andreas

Reply

Great tutorial. Took some time to figure out deploy keys in github but here are the steps that worked for me. cap production deploy kept failing because a permission denied error from github. Here's what I did

Mostly posting for future me 😁

  1. go through the ssh key gen process for the deploy user (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key)

  2. Add your key to the ssh agent on deploy https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent

  3. Add public key as a deploy key to the repository in github (https://docs.github.com/en/developers/overview/managing-deploy-keys#deploy-keys)

  4. Confirm this is working by ssh git@github.com from your deploy user.

  5. Try running cap production deploy from local machine

Some things to note:

  • This was on an ubuntu machine running nginx.
  • make sure the /home/deploy/.ssh directory is owned by the deploy user and not root. (this drove me nuts until I realized)
  • My deploy.rb has a repo_url like this set :repo_url, "git@github.com:YOUR_USER_NAME/REPOSITORY_NAME.git"

I can clean this up and get more detailed with commands if you're running into issues. Hope this helps!

Reply

Hi,

How many times do I deploy my rails app?
I want to know if I have to deploy my app whenever I modify my rails app.

Thank you for hepls in advance.

Reply

I am unable to run the app in production
Your Ruby version is 2.7.0, but your Gemfile specified 3.1.2
however ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
also deploy@agility:~/project-portalMK5/current$ rbenv versions
system

  • 3.1.2 (set by /home/deploy/project-portalMK5/current/.ruby-version) also Gemfile source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.1.2" also also .ruby-version 3.1.2 I have spent hours getting nowhere, appreciate any help.
Reply

Getting the error no running passenger app at /home/deploy/project-portalMK5/
the problem was in the
Change myapp to the name of your app. We'll use this same folder later on when we define our Capistrano deploy_to folder.

server {
listen 80;
listen [::]:80;

server_name _;
root /home/deploy/myapp/current/public; #bug was here should have been deploy not root

passenger_enabled on;
passenger_app_env production;

Reply

Thanks a lot for this tutorial!
I would only add:
If you want to have http2 enabled then you need to add http2 to the listen configuration of nginx:

server {

  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ...
Reply

can someone can help me pleaseM

Reply

Hi, is a good guide. cannot deploy. I get the following error, can you help me?

cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as user@xx.xxx.xxx.xxx: git exit status: 2
git stdout: Nothing written
git stderr: fatal: not a valid object name: master
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

Caused by:
SSHKit::Command::Failed: git exit status: 2
git stdout: Nothing written
git stderr: fatal: not a valid object name: master
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

Solved!

Add in deploy rb

set :branch, :main

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,453+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.