Rails credentials do not update on new deploys [duplicate] - ruby-on-rails

I've setup sidekiq for my application. I am placing my workers in a newly created subdirectory app/workers/. Presumably, rails is expected to autoload any subdirectories under app/. If I evaluate
puts ActiveSupport::Dependencies.autoload_paths
in a rails console, in development, it does include
".../app/workers"
In production however, the new directory is missing. Other custom folders I've placed under app/, namely services/ and validators/, do show up in the autoload_paths for both production and development.
I've seen answers to other questions that suggest restarting spring, however, this is happening in production for me.
services/ and validators/ existed the first time I deployed my app to production (using Capistrano), while workers/ is from a subsequent commit.

My unicorn deploy script included bin/ in the linked_dirs. Rails console is booted from bin so it needs to represent the current release. I removed bin/ from shared_dirs

Related

Custom directory that is under `app` is missing in production `autoload_paths`

I've setup sidekiq for my application. I am placing my workers in a newly created subdirectory app/workers/. Presumably, rails is expected to autoload any subdirectories under app/. If I evaluate
puts ActiveSupport::Dependencies.autoload_paths
in a rails console, in development, it does include
".../app/workers"
In production however, the new directory is missing. Other custom folders I've placed under app/, namely services/ and validators/, do show up in the autoload_paths for both production and development.
I've seen answers to other questions that suggest restarting spring, however, this is happening in production for me.
services/ and validators/ existed the first time I deployed my app to production (using Capistrano), while workers/ is from a subsequent commit.
My unicorn deploy script included bin/ in the linked_dirs. Rails console is booted from bin so it needs to represent the current release. I removed bin/ from shared_dirs

Webpacker deployment to production not creating manifest for some apps in Rails 5.2

I am stuck with deploying Rails apps in production with Webpacker.
Background: I am working on a custom set of Rails templates with the goal of reducing the friction when it comes to spiking new apps. Since the idea is to rapidly build and deploy new apps, I decided to use Webpack (since that is where the puck seems to be going). Using my template, I created 3 apps on my VM. I was able to get one of the three deployed and loading images, styles etc...but I am missing something with the other two. [* I was iterating on the template when I created the first app.]
Server Setup:
Ubuntu 17.10 x64
Rails 5.2.rc1
Ruby 2.5
Nginx
Puma
Webpacker
Capistrano 3.10.1
APPS: (one working, one not so much working)
1st: (This is the one that is working)
http://www.davechmura.com
https://github.com/dschmura/davechmura_website
2nd: (Not working)
http://www.arborguide.com/
https://github.com/dschmura/arborguide_website
When I look at the production log I am getting this
ERROR:
ActionView::Template::Error (Webpacker can't find application.css in /home/deployer/apps/arborguide_website/releases/20180224143553/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
):
Also, the arborguide_website/current/public/packs directory is empty. I am guessing that I need to address #4, but I cannot for the life of me figure out how it is working for the davechmura.com app and not the others.
I normally would have raised my hand earlier, but I am relatively new to Webpacker and thought it best to explore the field more. Now however, I am really stuck.
Your Capfile has capistrano/rails commented out:
# require 'capistrano/rails'
This means that cap deploy will not automatically run assets:precompile, which is what triggers the webpack build.

Rails server not working when copying back from staging deploy

I ssh copied a rails app from a staging server because the development repository has been lost. My goal is to create a new development code base using the deployed code as a source. So far I have removed a hidden .bundle folder and replaces several aliases with folders and files. I then ran bundle install. For the database I did a sql dump from staging and used it to build a development database. I think I'm ready to run rails server. But when I try to run rails server in the base directory. It gives me the rails command line help as if I was running rails s in a directory with no app.
I'm not even sure if it is possible to reverse a deploy this way. I've looked at the rails guide on the app initialization process and all the files seem to be in place.
Remember that for Rails to start up, you need bin/rails, bin/bundle, config/boot, etc.
If you restore those files, it should work again.

wrong fingerprint generation for assets with rails 4.x

Setup: Rails 4.2.5, Ubuntu 12.04, nginx 1.6, unicorn 5, capistrano 2.15
The setup did work with Rails 3.2 but once i started to migrate to rails 4.x i noticed an odd behaviour with the assets.
Inside the application the links to the asset files like application.js are not the ones inside the manifest.yml
If i do a deploy with asset cleanup, i will get many 404. The fingerprints used by the app and the manifest.yml differ.
If i do right away a second deploy without a cleanup, the assets will be served. They wont match with the manifest again, but the old ones are still in the folder. Killing unicorn and making a full restart did not change anything.
I have the same problem in the 4.0 and 4.1 branch of my app.
The assets are compiled on the server during deploy (capistrano scripts)
update:
I checked via console which fingerprints are generated and which files are present. Result: hashes are fine.
Problem is that the cleanup script deletes files older than a week or something and when doing a deploy (asset precompile) i get a wrong timestamp for some files.
If i do a precompile just now, some files have a datestamp 4th January and get deleted by the following cleanup script. Capistrano shows me some warning when writing that file but without any meaningfull information

Developing & deploying Rails app from same machine

I have started developing a new Rails app on my server using RVM, Rails 3, & Ruby v1.9.2. I am using Git as my code repository. It's a simple app and I don't want to use an extra server. I just want to deploy my app directly from the same server I am developing on.
I've installed Phusion Passenger w/ Apache to serve my app, but have realized that I can't do that pointing to my development directory as my RAILS_ENV is set to "development". (I found I got file permission errors on the asset pipeline and other issues when I attempted to set RAILS_ENV to "production" and serve the app)
What's the simplest/easiest way to deploy the app? Can I simply:
1) Create a separate user to run rails production (Rails in dev currently runs as me on my Ubuntu server)
2) Clone my repo into a separate dir and configure Apache accordingly
3) Seed my database with the data needed for production (not much data needed here)
4) What else?
I've looked briefly at Capistrano, but it seems like overkill for this simple app. I only need to be able to provide a simple web interface for some data entry. Seems like git push should be sufficient, but I haven't done this before so maybe I'm wrong? Also, if I git push how do I ensure file permissions in the "production" directories are all set properly, particularly for any new files that get created in the originating app directory structure?
Thanks for any ideas.
No- you do not need Capistrano for the above; at this stage I feel it will only serve to confuse you further.
I'd suggest you first save your repo to a private Github or free BitBucket account. What you should do is keep one folder for 'development'.
Remember that Passenger is 'just' a module working with Apache. So what you need to do is setup a virtual host under apache and direct that to another folder on your system. For this example, consider:
~/rails/myapp_development/ and ~/rails/myapp_production/
Passenger always runs the app in production, so that should not be an issue. You can do bundle --without=production in your development setup to ignore any gems listed in the Gemfile under the production namespace, i.e. say you've got the mysql adaptor specified, you can ignore this and have Rails only rely on the SQlite gem.
You can now simply develop in the development folder, commit, push to BitBucket. Deploying will be as simply going into the production folder and doing a git pull and touch tmp/restart.txt.

Resources