Remote server log production.log is empty - ruby-on-rails

Issue: log/production.rb file exists but is empty on production Rails 4.2 environment.
App root and permissions:
drwxrwxr-x 2 deploy deploy 4096 Mar 7 14:59 .
drwxrwxr-x 21 deploy deploy 4096 Mar 7 04:16 ..
-rw-rw-r-- 1 deploy deploy 0 Feb 6 17:13 .git_keep
-rw-rw-r-- 1 deploy deploy 95833941 Mar 9 05:16 newrelic_agent.log
-rwxrwxrwx 1 deploy deploy 80 Mar 9 01:16 production.log
-rw------- 1 deploy deploy 129287 Mar 7 08:24 production.searchd.log
-rw------- 1 deploy deploy 93957 Mar 9 05:06 production.searchd.query.log
-rw------- 1 deploy deploy 5 Feb 7 10:37 production.sphinx.pid
config/environments/production.rb
# If you have no front-end server that supports something like X-Sendfile,
# just comment this out and Rails will serve the files
config.log_level = :info
# Basic log config, for calls to Rails.logger.<level> { <message> }
config.logger = Logger.new('log/production.log')
# Formats log entries into: LEVEL MESSAGE
# Heroku adds to this timestamp and worker/dyno id, so datetime can be stripped
config.logger.formatter = ->(severity, datetime, progname, msg) { "#{severity} #{msg}\n" }
# Lograge config, overrides default instrumentation for logging ActionController and ActionView logging
config.lograge.enabled = true
Help please. Thank you for advance

Related

Rails does not start up due to LoadError (can't find file that exists)

I'm on an ubuntu 20.04
Had a rails application that used to run until last month.
But a certificate issue made me reinstall nginx and passenger and some dependencies.
However all rails commands (console, server, assets:precompile) are now failing with the following error
/home/deploy/mark_antony/shared/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': libffi.so.6: cannot open shared object file: No such file or directory - /home/deploy/mark_antony/shared/bundle/ruby/2.7.0/gems/ffi-1.13.1/lib/ffi_c.so (LoadError)
But when i check, everything seems perfectly fine.. the file does exist:
deploy#ubuntu-s-1vcpu:~/mark_antony/current$ cd /home/deploy/mark_antony/shared/bundle/ruby/2.7.0/gems/ffi-1.13.1/lib/
deploy#ubuntu-s-1vcpu:~/mark_antony/shared/bundle/ruby/2.7.0/gems/ffi-1.13.1/lib$ ll
total 476
drwxrwxr-x 3 deploy deploy 4096 Jan 7 19:08 ./
drwxrwxr-x 6 deploy deploy 4096 Jan 7 19:07 ../
drwxrwxr-x 4 deploy deploy 4096 Jan 7 19:07 ffi/
-rw-rw-r-- 1 deploy deploy 925 Jan 7 19:07 ffi.rb
-rwxr-xr-x 1 deploy deploy 467872 Jan 7 19:08 ffi_c.so*
Any idea on how to get the app working again?

Asset Precompile issue in RoR - Duplicate Assets

I am using rvm 2.2.1 version and trying to compile my assets locally and it is working properly.
Whenever I'm modifying something in app/assets, it is adding duplicate assets in my public/assets folder. I'm running the following commands to rebuild my codebase.
bundle exec rake RAILS_ENV=production assets:clean
bundle exec rake RAILS_ENV=production assets:precompile
Sample duplicate assets:
[webauto#web-ci-slave4-alpha shop]$ ls -lrt /var/lib/jenkins/test/shop/public/assets/hello-*
-rw-rw-r-- 1 webauto webauto 41 Sep 7 11:00 /var/lib/jenkins/test/shop/public/assets/hello-3781f94ea812bb33437de9049e04bc3af41a0e7397164b057379c08c3b0ac489.js.gz
-rw-rw-r-- 1 webauto webauto 21 Sep 7 11:00 /var/lib/jenkins/test/shop/public/assets/hello-3781f94ea812bb33437de9049e04bc3af41a0e7397164b057379c08c3b0ac489.js
-rw-rw-r-- 1 webauto webauto 54 Sep 7 11:05 /var/lib/jenkins/test/shop/public/assets/hello-c63e283c3fa4c225fee1e8efcc76ef9ff7ad217eac34344beb0441a946f13534.js.gz
-rw-rw-r-- 1 webauto webauto 87 Sep 7 11:05 /var/lib/jenkins/test/shop/public/assets/hello-c63e283c3fa4c225fee1e8efcc76ef9ff7ad217eac34344beb0441a946f13534.js
-rw-rw-r-- 1 webauto webauto 54 Sep 7 11:18 /var/lib/jenkins/test/shop/public/assets/hello-f55b89d4c36cfe653707589edc83607130db7014e1d8d4a4f9c9074b1dce224b.js.gz
-rw-rw-r-- 1 webauto webauto 131 Sep 7 11:18 /var/lib/jenkins/test/shop/public/assets/hello-f55b89d4c36cfe653707589edc83607130db7014e1d8d4a4f9c9074b1dce224b.js
-rw-rw-r-- 1 webauto webauto 54 Sep 7 11:39 /var/lib/jenkins/test/shop/public/assets/hello-bd8851907bef1e34c111190348f2c1945a04e96c3e5a6c5a252394794af093c5.js.gz
-rw-rw-r-- 1 webauto webauto 153 Sep 7 11:39 /var/lib/jenkins/test/shop/public/assets/hello-bd8851907bef1e34c111190348f2c1945a04e96c3e5a6c5a252394794af093c5.js
[webauto#web-ci-slave4-alpha shop]$
I am expecting to update the existing asset(s), not to add the new one which will grow my public folder with duplicate asset entries. Could anyone please help me with this?
Thanks in advance.
Regards,
Vennila K

Why is capistrano using git clone always

I have some basic issues with capistrano deployment. First of all, I need to know whether capistrano is using git clone even for the second or third when the git repo is already existing. Is there any issue if it uses git pull? I have added set :deploy_via, :remote_cache in my capfile. I am asking this because I tried adding a new file in the path in the server, and not in the git repo as it was a server specific file. The next time I deployed using capistrano, the file disappeared. It seems like capistrano is using git clone even when a git repo is already created. Why cant capistrano use git pull to update the code?
Capistrano creates a new subdirectory in realeases for each release like this
horse:releases xxx$ ls -lart
total 0
drwxrwxr-x 22 xxx staff 748 Jun 26 20:08 20120626180809
drwxrwxr-x 22 xxx staff 748 Jun 26 20:11 20120626181103
drwxrwxr-x 22 xxx staff 748 Jun 26 20:29 20120626182908
drwxrwxr-x 22 xxx staff 748 Jun 26 20:34 20120626183442
drwxrwxr-x 22 xxx staff 748 Jun 26 20:35 20120626183525
drwxrwxr-x 8 xxx staff 272 Jun 27 13:11 .
drwxrwxr-x 22 xxx staff 748 Jun 27 13:11 20120627111102
drwxrwxr-x 5 xxx staff 170 Jun 27 13:11 ..
and then simply sets a symlink to the current release like this
horse:deployed xxx$ ls -lart
total 8
drwxrwxr-x 4 xxx staff 136 Jun 26 19:51 ..
drwxrwxr-x 7 xxx staff 238 Jun 26 20:22 shared
drwxrwxr-x 8 xxx staff 272 Jun 27 13:11 releases
lrwxrwxr-x 1 xxx staff 70 Jun 27 13:11 current -> /Users/xxx/RailsDeployment/server/deployed/releases/20120627111102
This way, rollback of the deployment on the server is really easy as you just have to change the symlink back to the last (working) deployment, but as a new complete subdir is created each time it makes sense using git clone instead of git pull.
If you want to have server-specific files, you have to add a capistrano deploy task to your config/deploy.rb file to copy it from somewhere else outside the app directory (typically the shared subfolder). The reason for this is that the deployment should be fully automatic and document all necessary steps in an automated procedure, and not depend on files on the server that were put there manually as this is the first step to a snowflake server. So, if you need a file that is not part of your git repository, as typically something containing production passwords, you need to change config/deploy.rb to copy this file to where you need it. To see how to do this look at the copy_db_credentials tasks in my deploy.rb:
namespace :deploy do
desc "cause Passenger to initiate a restart"
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
desc "Copies database credentials"
task :copy_db_credentials do
run "cp #{shared_path}/credentials/database.yml #{current_path}/config/database.yml"
end
desc "reload the database with seed data"
task :seed do
run "cd #{current_path}; rake db:seed RAILS_ENV=#{rails_env}"
end
end
after :deploy, "deploy:copy_db_credentials"
after "deploy:update_code", :bundle_install
desc "install the necessary prerequisites"
task :bundle_install, :roles => :app do
run "cd #{release_path} && bundle install"
end

JBoss based rails application cant find activerecord-jdbcmysql-adapter

I have a rails application deployed to jboss as a war packaged using warbler. The application has been working great for a while now.
I am looking to change the rails application so that rails, all gems and their dependencies are vendor'd. To that extent I have it working great and can boot the application locally using mongrel with no issues, and can also build the war with no issues
However when I deploy the war to jboss it fails to load the application successfully saying it cant find activerecord-jdbcmysql-adapter.
2010-10-26 14:20:23,281 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/lmd4]] (main) unable to create shared application instance
org.jruby.rack.RackInitializationException: Please install the jdbcmysql adapter: `gem install activerecord-jdbcmysql-adapter` (no such file to load -- active_record/connection_adapters/jdbcmysql_adapter)
This is what i have done so far:
Make sure config/warble.rb has an entry for activerecord-jdbcmysql-adapter
config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl"]
Manually unpacked the war and confirmed the gems are present
WEB-INF/gems/gems
drwxrwxr-x 7 4096 Oct 26 14:14 activerecord-jdbc-adapter-1.0.2-java
drwxrwxr-x 3 4096 Oct 26 14:14 activerecord-jdbcmysql-adapter-1.0.2-java
drwxrwxr-x 3 4096 Oct 26 14:14 bouncy-castle-java-1.5.0145.2
drwxrwxr-x 3 4096 Oct 26 14:14 jdbc-mysql-5.0.4
drwxrwxr-x 4 4096 Oct 26 14:14 jruby-openssl-0.7.1
drwxrwxr-x 7 4096 Oct 26 14:14 rack-1.1.0
WEB-INF/vendor/gems
drwxrwxr-x 7 4096 Oct 26 14:14 activerecord-jdbc-adapter-1.0.2-java
drwxrwxr-x 3 4096 Oct 26 14:14 activerecord-jdbcmysql-adapter-1.0.2-java
drwxrwxr-x 3 4096 Oct 26 14:14 bouncy-castle-java-1.5.0145.2
drwxrwxr-x 5 4096 Oct 26 14:14 fastercsv-1.5.3
drwxrwxr-x 12 4096 Oct 26 14:14 hobo-1.0.1
drwxrwxr-x 7 4096 Oct 26 14:14 hobofields-1.0.1
drwxrwxr-x 4 4096 Oct 26 14:14 hobosupport-1.0.1
drwxrwxr-x 3 4096 Oct 26 14:14 jdbc-mysql-5.0.4
drwxrwxr-x 4 4096 Oct 26 14:14 jruby-openssl-0.7.1
drwxrwxr-x 4 4096 Oct 26 14:14 json-1.4.6-java
drwxrwxr-x 2 4096 Oct 26 14:14 json-jruby-1.4.6-java
drwxrwxr-x 7 4096 Oct 26 14:14 rack-1.1.0
drwxrwxr-x 4 4096 Oct 26 14:14 will_paginate-2.3.15
I dunno what could be causing this but if anyone has any ideas please share?
JBoss 5
Rails 2.3.10
JRuby 1.5
Thanks
Could be a JBoss/JRuby-Rack interaction issue. We've had some reports in the past of this not working due to JBoss' use of VFS in class and resource paths and URLs. You could be tripping on this as well.
Can you try the same war file in Tomcat 6 to isolate JBoss as part of the equation? Then please post a bug at http://kenai.com/jira/browse/JRUBY_RACK or http://bugs.jruby.org/.

Thinking Sphinx not working in test mode

I'm trying to get Thinking Sphinx to work in test mode in Rails. Basically this:
ThinkingSphinx::Test.init
ThinkingSphinx::Test.start
freezes and never comes back.
My test and devel configuration is the same for test and devel:
dry_setting: &dry_setting
adapter: mysql
host: localhost
encoding: utf8
username: rails
password: blahblah
development:
<<: *dry_setting
database: proj_devel
socket: /tmp/mysql.sock # sphinx requires it
test:
<<: *dry_setting
database: proj_test
socket: /tmp/mysql.sock # sphinx requires it
and sphinx.yml
development:
enable_star: 1
min_infix_len: 2
bin_path: /opt/local/bin
test:
enable_star: 1
min_infix_len: 2
bin_path: /opt/local/bin
production:
enable_star: 1
min_infix_len: 2
The generated config files, config/development.sphinx.conf and config/test.sphinx.conf only differ in database names, directories and similar things; nothing functional.
Generating the index for devel goes without an issue
$ rake ts:in
(in /Users/pupeno/proj)
default config
Generating Configuration to /Users/pupeno/proj/config/development.sphinx.conf
Sphinx 0.9.8.1-release (r1533)
Copyright (c) 2001-2008, Andrew Aksyonoff
using config file '/Users/pupeno/proj/config/development.sphinx.conf'...
indexing index 'user_core'...
collected 7 docs, 0.0 MB
collected 0 attr values
sorted 0.0 Mvalues, 100.0% done
sorted 0.0 Mhits, 99.8% done
total 7 docs, 422 bytes
total 0.098 sec, 4320.80 bytes/sec, 71.67 docs/sec
indexing index 'user_delta'...
collected 0 docs, 0.0 MB
collected 0 attr values
sorted 0.0 Mvalues, nan% done
total 0 docs, 0 bytes
total 0.010 sec, 0.00 bytes/sec, 0.00 docs/sec
distributed index 'user' can not be directly indexed; skipping.
but when I try to do it for test it freezes:
$ RAILS_ENV=test rake ts:in
(in /Users/pupeno/proj)
DEPRECATION WARNING: require "activeresource" is deprecated and will be removed in Rails 3. Use require "active_resource" instead.. (called from /Users/pupeno/.rvm/gems/ruby-1.8.7-p249/gems/activeresource-2.3.5/lib/activeresource.rb:2)
default config
Generating Configuration to /Users/pupeno/proj/config/test.sphinx.conf
Sphinx 0.9.8.1-release (r1533)
Copyright (c) 2001-2008, Andrew Aksyonoff
using config file '/Users/pupeno/proj/config/test.sphinx.conf'...
indexing index 'user_core'...
It's been there for more than 10 minutes, the user table has 4 records.
The database directory look quite diferently, but I don't know what to make of it:
$ ls -l db/sphinx/development/
total 96
-rw-r--r-- 1 pupeno staff 196 Mar 11 18:10 user_core.spa
-rw-r--r-- 1 pupeno staff 4982 Mar 11 18:10 user_core.spd
-rw-r--r-- 1 pupeno staff 417 Mar 11 18:10 user_core.sph
-rw-r--r-- 1 pupeno staff 3067 Mar 11 18:10 user_core.spi
-rw-r--r-- 1 pupeno staff 84 Mar 11 18:10 user_core.spm
-rw-r--r-- 1 pupeno staff 6832 Mar 11 18:10 user_core.spp
-rw-r--r-- 1 pupeno staff 0 Mar 11 18:10 user_delta.spa
-rw-r--r-- 1 pupeno staff 1 Mar 11 18:10 user_delta.spd
-rw-r--r-- 1 pupeno staff 417 Mar 11 18:10 user_delta.sph
-rw-r--r-- 1 pupeno staff 1 Mar 11 18:10 user_delta.spi
-rw-r--r-- 1 pupeno staff 0 Mar 11 18:10 user_delta.spm
-rw-r--r-- 1 pupeno staff 1 Mar 11 18:10 user_delta.spp
$ ls -l db/sphinx/test/
total 0
-rw-r--r-- 1 pupeno staff 0 Mar 11 18:11 user_core.spl
-rw-r--r-- 1 pupeno staff 0 Mar 11 18:11 user_core.tmp0
-rw-r--r-- 1 pupeno staff 0 Mar 11 18:11 user_core.tmp1
-rw-r--r-- 1 pupeno staff 0 Mar 11 18:11 user_core.tmp2
-rw-r--r-- 1 pupeno staff 0 Mar 11 18:11 user_core.tmp7
Nothing gets added to a log when this happens. Any ideas where to go from here?
I can run the command line manually:
/opt/local/bin/indexer --config config/test.sphinx.conf --all
which generates the output as the rake ts:in, so no help there.
The problem was the random ids generated by fixtures. The solution is described on http://freelancing-god.github.com/ts/en/common_issues.html#slow_indexing
Slow Indexing
If Sphinx is taking a
while to process all your records,
there are a few common reasons for
this happening. Firstly, make sure you
have database indexes on any foreign
key columns and any columns you filter
or sort by.
Secondly – are you using fixtures?
Rails’ fixtures have randomly
generated IDs, which are usually
extremely large integers, and Sphinx
isn’t set up to process disparate IDs
efficiently by default. To get around
this, you’ll need to set
sql_range_step in your
config/sphinx.yml file for the
appropriate environments:
development:
sql_range_step: 10000000
I added it to both, development and test environments.

Resources