Capistrano error on rake assets:precompile:all but still working (using RVM) - capistrano

I've made a new Rails 3.2 application. When i deploy it with Capistrano, I get an error when compiling assets. But the assets ARE compiled, and the application deployed as it should.
On the server I've installed RVM systemwide and then created:
User: skolemapicture (added to group rvm)
Deploy folder: /home/skolemapicture/site
.rvmrc in /home/skolemapicture/site/.rvmrc
My deploy.rb config looks like this (omitted lines that have nothing to do with the problem)
set :application, "skolemapicture"
set :deploy_to , "/home/skolemapicture/site"
set :user , "skolemapicture"
set :use_sudo , false
ssh_options[:forward_agent] = true
require "bundler/capistrano"
require "rvm/capistrano"
set(:ruby_version) { '1.9.3' }
set(:rvm_ruby_string) { "#{ruby_version}##{application}" }
set(:rvm_path) { "/usr/local/rvm" }
set(:rvm_type) { :system }
namespace :deploy do
task :precompile, :role => :app do
run "cd #{release_path}/ && bundle exec rake assets:precompile"
end
end
after "deploy:finalize_update", "deploy:precompile"
The error i get at "cap deploy" is:
* 2013-02-13 10:36:21 executing `deploy:precompile'
* executing "cd /home/skolemapicture/site/releases/20130213093619/ && bundle exec rake assets:precompile"
servers: ["web01.mapicture.com"]
[web01.mapicture.com] executing command
*** [err :: web01.mapicture.com] /usr/local/rvm/rubies/ruby-1.9.3-p374/bin/ruby /home/skolemapicture/site/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: web01.mapicture.com]
But the assets ARE compiled. So why this error?
/ Carsten

It is probably actually precompiling the assets successfully with your custom deploy:precompile task.
It is failing on the capistrano default assets:precompile task.
You will notice that the failed command is
/usr/local/rvm/rubies/ruby-1.9.3-p374/bin/ruby /home/skolemapicture/site/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
not your custom precompile task:
cd #{release_path}/ && bundle exec rake assets:precompile
Try removing your deploy:precompile task and adding
load 'deploy/assets'
to your Capfile if it is not already there.
If that doesn't fix it can you post your entire Capfile and deploy.rb?

Related

BitBake recipe for custom setup.py

In my recipe I have to download git repository and run CMake. After CMake finish its work additional directory OUT is created which contain setup.py file that I like to run in do_install?
I have tried:
DEPENDS = "setuptools python"
do_install () {
python OUT/setup.py install
}
But it raise no setup.py found error.
Can anyone deal with such issue?
That's happen because bitbake doesn't know where setup.py is stored - You need to use ${S} variable generated by bitbake to provide full path to this script.
Please read about how do_install() task work - link
At the moment I have reorganized my recipe which looks like below:
LICENSE = "CLOSED"
BB_STRICT_CHECKSUM = "0"
inherit cmake setuptools pythonnative
DEPENDS = "boost udev python swig-native python-native python-setuptools-native cmake-native"
SRC_URI = " \
git://github.com/my_repo.git;name=my_name \
file://0001-system-install.patch \
"
SRCREV_my_name = "404ff3eeff0d79c15cbfdbc126c4bff2996baea6"
S = "${WORKDIR}/git"
PARALLEL_MAKEINST = ""
Project downloaded from git base on CMake which has install like that:
install(CODE "execute_process(COMMAND python \"${PROJECT_SOURCE_DIR}/python/setup.py\" \"install\")")
But when I call recipe to build (bitbake my_recipe) or build image which contains that recipe (bitbake my_image) i received such error:
ERROR: pc-ble-driver-git-r0 do_compile: python setup.py build execution failed.
ERROR: pc-ble-driver-git-r0 do_compile: Function failed: do_compile (log file is located at /build/yocto-fsl/build/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/pc-ble-driver/git-r0/temp/log.do_compile.16502)
ERROR: Logfile of failure stored in: /build/yocto-fsl/build/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/pc-ble-driver/git-r0/temp/log.do_compile.16502
Log data follows:
| DEBUG: Executing shell function do_compile
| ERROR: python setup.py build execution failed.
| /build/yocto-fsl/build/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/pc-ble-driver/git-r0/recipe-sysroot-native/usr/bin/python-native/python: can't open file 'setup.py': [Errno 2] No such file or directory
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_compile (log file is located at /build/yocto-fsl/build/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/pc-ble-driver/git-r0/temp/log.do_compile.16502)
ERROR: Task (/build/yocto-fsl/sources/meta-slabs/recipes-external/pc-ble-driver/pc-ble-driver_git.bb:do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 2195 tasks of which 2194 didn't need to be rerun and 1 failed.
P.S. On my PC when I build CMake project and call make install everything go as I assumed.
Any other suggestion how to deal with that?
Try add below command in your recipe file
distutils_do_compile() {
:
}
distutils_stage_headers() {
:
}
distutils_stage_all() {
:
}
distutils_do_install() {
:
}
and see more detail information below...
./poky/meta/classes/distutils-tools.bbclass

Travis-CI build - PhantomJS error preventing QUnit tests from running

I have a repository with a simple js function and a QUnit test. I have attempted to integrate it with Travis-CI using a grunt task. Everything works fine locally but PhantomJS throws an error during the build process preventing my tests from running.
Build:
https://travis-ci.org/DaveKingsnorth/ciSandbox/builds/40909225
Repo:
https://github.com/DaveKingsnorth/ciSandbox
//.travis.yaml
language: node_js
node_js:
- "0.11"
before_install: npm install -g grunt-cli
install: npm install
// Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: '<json:package.json>',
qunit: {
src: ['test/**/*.html']
}
});
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.registerTask('test', ['qunit']);
grunt.registerTask('default', 'qunit');
};
Error:
Testing test/index.html
PhantomJS threw an error:ERROR
/home/travis/build/DaveKingsnorth/ciSandbox/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: 4: /home/travis/build/DaveKingsnorth/ciSandbox/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: Syntax error: Unterminated quoted string 0 [ '/home/travis/build/DaveKingsnorth/ciSandbox/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: 4: /home/travis/build/DaveKingsnorth/ciSandbox/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: Syntax error: Unterminated quoted string' ]
Warning: PhantomJS exited unexpectedly with exit code 2. Use --force to continue.
Aborted due to warnings.
The command "npm test" exited with 0.
Done. Your build exited with 0.

correct way to create symlink in deploy.rb

I have an error when i deploy an application:
[neon.locum.ru] executing command
*** [err :: neon.locum.ru] find: `/home/hosting_grandinvest/projects/demo/releases/20130116145843/public/images /home/hosting_grandinvest/projects/demo/releases/20130116145843/public/stylesheets /home/hosting_grandinvest/projects/demo/releases/20130116145843/public/javascripts': Нет такого файла или каталога
command finished in 91ms
triggering after callbacks for `deploy:update_code'
* 2013-01-16 16:58:45 executing `make_images_link'
* executing "ln -s /home/hosting_grandinvest/projects/demo/shared/public/images /home/hosting_grandinvest/projects/demo/releases/20130116145843/public/images"
As you see it's because first it tries to find /public/images dir. and only then creates a symlink for that directory.
beggining of my deploy.rb
require 'bundler/capistrano'
after "deploy:update_code", :make_images_link
task :make_images_link, roles => :app do
images_dir = "#{shared_path}/public/images"
run "ln -s #{images_dir} #{release_path}/public/images"
end
the deploy finishes
Gem.source_index called from /home/hosting_grandinvest/projects/demo/shared/gems/ruby/1.8/gems/rails-2.3.15/lib/rails/gem_dependency.rb:21.
master process ready
worker=0 ready
reaped #<Process::Status: pid=18656,exited(0)> worker=0
master complete
in public/images dir are located some files used by css ( background: url(/images/front/logo.gif) no-repeat 0 0;) and they are Not displayed !but when i try to access these files directly
(http://hosting.net/images/front/logo.gif) i can see them!
Any suggestions on how to solve this error and make capistrano work?
UPDATE 1
I've included public/images/front in repo and after code deployment swap empty folder with a link
after "deploy:update_code", :make_images_link
task :make_images_link, roles => :app do
images_dir = "#{shared_path}/public/images"
realease_images = "#{release_path}/public/images"
run "rm -rf #{realease_images}"
run "ln -s #{images_dir} #{realease_images}"
end
When i deploy error still exists, but images appeared!
In the end i've included 'public'images' dir in my repository.
and as step 2 i run a callback that i've specified in update 1.

Rails: Queue Classic with Capistrano

I want to start Queue Classic (QC) within my Capistrano recipe:
namespace :queue_classic do
desc "Start QC worker"
task :start, roles: :web do
run "cd #{release_path} && RAILS_ENV=production bundle exec rake qc:work"
end
after "deploy:restart", "queue_classic:restart"
end
Capistrano runs the line correctly, so that the QC worker starts, but not as a daemon. As a result Capistrano won't continue to run the recipes.
How can I start the QC worker in the background and let Capistrano finish its tasks?
Thank you!
I use foreman for this:
after "deploy:update", "foreman:export" # Export foreman scripts
after "deploy:restart", "foreman:restart" # Restart application scripts
after "deploy:stop", "foreman:stop" # Restart application scripts
after "deploy:start", "foreman:start"
# Foreman tasks
desc 'Export the Procfile to Ubuntu upstart scripts'
task :export, :roles => :queue do
run "cd #{release_path}; #{sudo} $(rbenv which foreman) export upstart /etc/init -f ./Procfile -a #{application} -u #{user} -l #{release_path}/log/foreman"
end
desc "Start the application services"
task :start, :roles => :queue do
run "#{sudo} start #{application}"
end
desc "Stop the application services"
task :stop, :roles => :queue do
run "#{sudo} stop #{application}"
end
desc "Restart the application services"
task :restart, :roles => :queue do
run "#{sudo} stop #{application}"
run "#{sudo} start #{application}"
#run "sudo start #{application} || sudo restart #{application}"
end
Then in your Procfile put something like
worker: RAILS_ENV=production bundle exec rake qc:work
Use the & sign at the and and put process in background.
run "cd #{release_path} && RAILS_ENV=production bundle exec rake qc:work &"
Killin and restarting is than a bit tricky, but it could be done using ps, grep and kill.

Capistrano cannot find SVN client

I have an SVN client locally and on the Solaris production server, and they are in my path, so when I type svn somethng the command is found (my PC and Solaris).
This is the error:
C:\dev\apps>cap deploy:migrations
* executing `deploy:migrations'
* executing `deploy:update_code'
executing locally: "svn info https://svn.domain.co.uk/svn/apps -rHEAD"
*** executable 'svn' not present or not in $PATH on the local system!
* executing "svn checkout -q -r6 https://svn.domain.co.uk/svn/apps /sites/r
ails-data/apps/releases/20100120114312 && (echo 6 > /sites/rails-data/apps/relea
ses/20100120114312/REVISION)"
servers: ["solaris001.ds.domain.com"]
Password:
[solaris001.ds.domain.com] executing command
** [solaris001.ds.domain.com :: err] ld.so.1: svn: fatal: libaprutil-1.so.
0: open failed: No such file or directory
** [solaris001.ds.domain.com :: err] Killed
command finished
failed: "sh -c 'svn checkout -q -r6 https://svn.domain.co.uk/svn/apps /sites/
rails-data/apps/releases/20100120114312 && (echo 6 > /sites/rails-data/apps/rele
ases/20100120114312/REVISION)'" on solaris001.ds.domain.com
In my PC and in Solaris I can successfully run the commands that Capistrano is unable it cannot find the library and the executable.
This is my recipe:
set :application, "apps"
set :user, 'me'
set :domain, "solaris001.ds.domain.com"
set :repository, "https://svn.domain.co.uk/svn/apps"
set :use_sudo, false
set :deploy_to, "/sites/rails-data/#{application}"
role :app, domain
role :web, domain
namespace :deploy do
task :start, :roles => :app do
run "touch #{current_release}/tmp/restart.txt"
end
task :stop, :roles => :app do
# Do nothing.
end
desc "Restart Application"
task :restart, :roles => :app do
run "touch #{current_release}/tmp/restart.txt"
end
end
The solution: http://riccardotacconi.blogspot.com/2010/01/rails-deployment-with-capistrano-and.html