Error deploying assets with Capistrano 2.15.5 on Rails 4 - ruby-on-rails-4

I'm having a bazaar error occur when deploying my Rails 4 application with Capistrano 2.15.5. This is an app that i am migrating from Rails 3.2, and this is my first deployment attempt with this version of Capistrano and Rails 4.
It appears to be seriously munging the release path, here is the output from Capistrano:
* executing "cp -- /www/awesome_app/shared/assets/manifest-4f237c854d9f335aac16f877929b75a8.json /www/awesome_app/releases/\\\e\\[34m20140417213248\\\e\\[39\\;49m\\\e\\[0m/assets_manifest.json"
servers: ["staging.private"]
[staging.private] executing command ** [out :: staging.private] cp: /www/awesome_app/releases/\033[34m20140417213248\033[39;49m\033[0m/assets_manifest.json: No such file or directory
command finished in 613ms
*** [deploy:update_code] rolling back
The asset manifest file gets created ok:
/www/awesome_app/shared/assets/manifest-4f237c854d9f335aac16f877929b75a8.json
But the cp command it is generating has a totally messed up path:
/www/awesome_app/releases/\\\e\\[34m20140417213248\\\e\\[39\\;49m\\\e\\[0m/assets_manifest.json
This path contains the date, as it should, but also a bunch of what look like escaped characters.
Has anyone seen this or know what is going on here?
thanks!

Answer: upgrade to Capistrano 3.x
After doing that, my rails 4 app deployed without issues.
Still no idea what the underlying problem here was.

Related

Non-starting rails 5.2 app - ActiveSupport::MessageEncryptor::InvalidMessage

I have deployed two rails apps to Digital Ocean, Ubuntu 18.04 with Passenger and Nginx.
Both apps were built on rails 5.2.2 with ruby 2.5.1, and the second app has all the same gems at the same versions. While the first app runs fine, the second will not launch.
The last useful line of the Passenger log says:
[ E 2020-08-06 22:41:56.6186 30885/T1i age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/html/AppName_Prod/current: The application encountered the following error: ActiveSupport::MessageEncryptor::InvalidMessage (ActiveSupport::MessageEncryptor::InvalidMessage)
I know this is somethign to do with the master.key file, but that is present and contains the correct key. I'm not using environment vars to store the master keys - they are in the master.key file inside each app's dir structure.
I've read every SO post I could find on this and none have solved my issue.
Any suggestions for getting these two apps (and more) to work on the same droplet?
I'm all out of ideas.
Thank you for any help you can offer.
For anyone who might have the same issue, it was a bit deceptive.
I had tried rails credentials:edit and it didn't fix the issue, but I found that the app's containing folder was owned by user:user, whereas my other app was owned by user:root.
When I changed this, everything started to work.
I hope it helps someone because I didn't find this info anywhere online and it was a lot of trial and error.
Use ls -l to list the current owner of folders in the current working directory, so you can compare them.
For me, this turned out to be somewhat complicated. I had provisioned my server using Ansible, which has a task to copy the Nginx conf. After provisioning the server, I changed RAILS_MASTER_KEY.
It turns out that my Ansible task does not re-write the Nginx conf if it already exists on the server (the file is not compared, I guess). So although I updated RAILS_MASTER_KEY in my Ansible playbook (and it was even getting copied across to the server's environment variables!), it was not accessible to Rails through passenger because it does not pass on the user's environment variables.
Whew!
To fix this (and create a snowflake server in the process...) I manually logged into the server and updated RAILS_MASTER_KEY to my new value in the Nginx passenger_env_var.

Rails: How to set up db:schema:load for initial deploy with Capistrano

I'm trying to deploy my Rails 4 app using Capistrano 3. I'm getting error messages in running the db:migrations (i've been sloppy, sorry). Is there a way to have Capistrano deploy the app (at least the first time) using db:schema:load?
An excerpt of my deploy.rb:
namespace :deploy do
%w[start stop restart].each do |command|
desc 'Manage Unicorn'
task command do
on roles(:app), in: :sequence, wait: 1 do
execute "/etc/init.d/unicorn_#{fetch(:application)} #{command}"
end
end
end
I'm not sure how to override Capistrano 3's default behaviour. Can someone tell me how to add this to my script?
For first time deploys, I generally hack around it by logging into the server, cding into the release directory (which will have the deployed code at this point), and then manually running RAILS_ENV=yourenv bundle exec rake db:setup.
In Capistrano 3.10.1 with a Rails 5.1.6 application,
~/Documents/p.rails/perla-uy[staging]$ bundle exec cap staging deploy:updating
gives me enough to shell-in and run the db:structure:load or db:schema:load task manually. In the secure shell session to the host, switch to the newly created release directory and:
dclo#localhost:~/perla-uy/releases/20180412133715$ bundle install --without development test --deployment
dclo#localhost:~/perla-uy/releases/20180412133715$ bundle exec rails db:schema:load
Shelling into a (successful or failed) deploy that has tried deploy:migrate isn't quite the same.
Note: I have RAILS_ENV=production and RAILS_MASTER_KEY=... set-up by the shell login.

haystack.exceptions.MissingDependency: The 'elasticsearch' backend requires the installation of 'elasticsearch'

I am newbie to Django-haystack. I got an error while following Django-Haystack documentation.
Command execution order, I followed:
I started elasticsearch server (1.7.3) using command prompt and I am able to access http://127.0.0.1:9200/
python manage.py rebuild_index
Output:
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the rebuild_index command.
Are you sure you wish to continue? [y/N] y
Error:
packages\haystack\backends\elasticsearch_backend.py", line 28, in
raise MissingDependency("The 'elasticsearch' backend requires the installation of 'elasticsearch'. Please refer to the documentation.")
haystack.exceptions.MissingDependency: The 'elasticsearch' backend requires the installation of 'elasticsearch'. Please refer to the documentation.
Current Platform (Windows):
1. Django 1.8
2. elasticsearch: 1.9.0 (installed through pip)
3. pyelasticsearch: 0.0.5 (installed through pip)
4. elasticseach: 1.7.3 (downloaded to start elasticsearch server)
I have tried adding the 'elasticsearch' also to my installed apps but the same error exists.
It seems there is version compatibility problems (perhaps in pyelasticseach) as I found some others also faced the same issue. Any help would be appreciated. Thanks.

Django Deploy From Github to Server Like Capistrano with Simple Fabric Recipe

I wanted to use Capistrano to deploy on my django app on my webfaction server but due to my purist tendencies, I wanted to do it in Fabric, in a way that Capistrano does. The thing that I liked most about about Capistrano is that automatically retrieves a repo's content and pushes it to a server.
The fabric recipes I have seen so far required me to do things "the git way", manually entering git commands to work with the repo, etc.
Is there a way to deploy a Django app in Fabric (or any other python package) "the Capistrano" way?
Sie Note: In case I really have to work with Capistrano, is there a way to bypass the assets precompile task and the rake db:migrate task?
Ive successfully used the scripts from here to deploy to webfaction.
If you want to bypass the assets compilation, just don't write this line in your recipe :
load 'deploy/assets'
If you don't want to run migration, just never type the migration command
cap deploy:migrate
If you want to remove some other behaviors (symlink, restart, update code to server) write chosen parts from this :
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart do ; end
task :update_code do ; end #override this task to prevent capistrano to upload on servers
task :symlink do ; end #don't create the current symlink to the last release
end
for anyone who stumbles across this, here is a capistrano recipe that is so basic :
http://ygamretuta.me/2012/07/18/deploy-django-1-4-webfaction-capistrano/

ColdFusion 8 as WAR on JBoss 4.2.3 WEB-INF/flex-config.xml error

I have done this by the book multiple times and have also tried using someone else's WAR to deploy, but I keep getting the same error. I am running JBoss 4.2.3 and have tried this on multiple installations (of 4.2.3)
I have verified that the supposed missing file file exists.
19:19:15,853 INFO [ContextLoader] Root WebApplicationContext: initialization completed in 54014 ms
19:19:18,172 ERROR [STDERR] javax.servlet.ServletException: The configuration file cound not be found at /WEB-INF/cfform/flex-config.xml
19:19:18,174 ERROR [STDERR] at flex.server.j2ee.cache.CacheFilter.setupFlexService(CacheFilter.java:93)
This error results in failure of the WAR to deploy:
--- MBeans waiting for other MBeans ---
ObjectName: jboss.web.deployment:war=cfusion.war,id=611163449
State: FAILED
Reason: org.jboss.deployment.DeploymentException: URL file:/jee/workspace/tools/server/default/deploy/cfusion.war/ deployment failed
Any ideas?
I found a solution. It's insane, but it's worked twice now (on OS X, at least).
copy the WEB-INF directory to your file system root.
Ex: cp -R ./cfusion.war/WEB-INF /
start the instance. Everything works.
Delete the newly copied file system root /WEB-INF folder.
From now on, it will work. Crazy, but there you go.
I've seen this one a million times. It's usually when I forget a file in the WEB-INF of my war. Is flex-config.xml in your WEB-INF?