Rails terminal commands run after 12 seconds why? - performance

I am using ruby since 2 months i did small projects with express.js and django before.
My question is:
$ rails generate migration ...
$ rake db:migrate ...
$ rails console...
Why theese commands run after ~~12 seconds.?
I am using sqlite3. Rails 6.0.0
My rails settings:
=> Booting Puma
=> Rails 6.0.2.2 application starting in development
=> Run `rails server --help` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 4.3.3 (ruby 2.6.6-p146), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
On the other hand ruby, python, node shell, django dev server and express.js server commands running super fast.
Am i doing something wrong?
But i don't understand why making just one migration file command waits ~12 seconds to run?
Example:
This command runs after waiting 12 secs. I am using powershell and windows terminal.
C:\Users\xxxx\Documents\ruby\xxxxxx\xxxxx> rails db:rollback
== 20200421123726 AddPartyIdToElections: reverting ============================
-- remove_column(:elections, :party_id, :int, {:before=>:created_at})
-> 0.0630s
== 20200421123726 AddPartyIdToElections: reverted (0.0713s) ===================
os windows 10
Intel® Core™ i5-6200U CPU # 2.30GHz
8 gb ram
toshiba 250 gb ssd
This slowness reduce my learning curve. I want to solve this.

Ok it seems this stiuation normal on windows machines. I tried linux mint it is faster than windows.
Also there is a gem for fastering commands speed.
http://railscasts.com/episodes/412-fast-rails-commands

Related

Jenkins Build, Execute Shell Error

I'm trying to trigger a shell command via Jenkins 2.54 on Build. I've had this running in the past but decided to rebuild my mac 'clean' without TimeMachine..
In the background, i'm using a node.js app for building applications in Agile Central (Rally) - All of this works fine and even the shell command I use runs in the Shell (Fish to be precise).
As far as I can tell I have all the dependancies installed as this works when running from cmd line..
The command I'm using:
ruby /g2ca/git2ca_agile_central.rb devOps
As mentioned in the shell directly this does everything I need, takes a commit with an artefact ID such as a user story US01 and adds the expected outcome to the user stories Change Set:
BUT.. Jenkins throws a fit in it's console:
+ ruby /g2ca/git2ca_agile_central.rb devOps /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require': cannot load such file -- vcseif (LoadError) from
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require' from /g2ca/git2ca_agile_central.rb:35:in `' Build
step 'Execute shell' marked build as failure
I'm no professional coder by any stretch!!! So go easy here as I could be way out of my depth, but this is baffling me..
I'm using Brew also, if it helps here is the output from
Brew Config
HOMEBREW_VERSION: 1.1.12
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 8ea778f7c7ea790694485030d105a92a9416ef33
Last commit: 9 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 55a35bb74627e9eee9537dc726ac07c3dbc59444
Core tap last commit: 7 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.0.0-p648
Clang: 8.1 build 802
Git: 2.11.0 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.4.1_1/bin/ruby
Java: 1.8.0_121
macOS: 10.12.4-x86_64
Xcode: 8.3.1
CLT: N/A
X11: N/A
Do I have a ruby missmatch between my shell and Jenkins??
Here's what i'm using:
RallyConnectorForGit-3.7_3
Node 5.4.1
rally_api 1.2.1
httpclient 2.8.3
vcseif 1.2.0
Jenkins 2.54
I'm lost... Anything else you need please shout!
This is fixed was ruby version on HBrew

Grape stand alone rest api ERROR: No application configured, nothing to run

I have followed this tutorial step by step: https://wildandcrazytutorials.wordpress.com/2016/03/05/how-to-build-a-grape-standalone-rest-api/
However I get the error:
Puma starting in single mode...
Version 3.6.2 (ruby 2.2.2-p95), codename: Sleepy Sunday Serenity
Min threads: 0, max threads: 16
Environment: development
ERROR: No application configured, nothing to run
when I run puma in In ./myapp
I am running it on a MacOs.
I am new to grape and I would love some guidance. I have literally simply followed the tutorial up to "Run the following to startup the server after every change…
In ./myapp
$ puma"
I got my answer from Daniel # https://groups.google.com/forum/#!forum/ruby-grape
There was a syntax error, his code below fixed my problem, I appreciate it.
require 'rubygems'
require 'grape'
Dir.glob("**/*.rb").each do |f|
puts "Loaded #{f}"
require_relative "../#{f}" unless File.absolute_path(f) == __FILE__
end

delayed_job gem - NotImplementedError: fork is not available on this platform

I am using jruby (1.7.3 or 1.7.9), delayed_job (1.8.4), daemons (1.1.9) gems for my rails 2.3.17 application.
I am trying to start the delayed job server using command:
1. jruby script/delayed_job start
Error:
RuntimeError: ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable
each_object at org/jruby/RubyObjectSpace.java:173
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:39
(root) at script/delayed_job:5
To resolve this error, I passed "-X+O" option & ran following command:
jruby -X+O script/delayed_job start
This has resolved "ObjectSpace is disabled" error but I am getting following error on local.
Error:
NotImplementedError: fork is not available on this platform
fork at org/jruby/RubyKernel.java:1880
safefork at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/daemonize.rb:11
call_as_daemon at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/daemonize.rb:43
start_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/application.rb:259
start at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/application.rb:296
run at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/controller.rb:70
run_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons.rb:197
call at org/jruby/RubyProc.java:290
call at org/jruby/RubyProc.java:224
catch_exceptions at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109
run_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons.rb:196
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:45
times at org/jruby/RubyFixnum.java:280
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:43
(root) at script/delayed_job:5
Anyone can help me to resolve this error.
Locally I am able to start my server using "jrake jobs:work" command but I am not whether I can use "jrake jobs:work" instead of "jruby script/delayed_job start".
Thanks.
You cannot use delayed_job on jruby because it relies on Fork which is not available in jruby.

merb - wkhtmltopdf command failed

when am running command like this its generating pdf document:
$ wkhtmltopdf http://google.com google.pdf
Loading pages (1/5)
Resolving links (2/5)
Counting pages (3/5)
Printing pages (5/5)
Done
But when using inside app by pdfkit gem it showing error
merb : worker (port 4000) ~ command failed: "/usr/local/bin/wkhtmltopdf" "--page-size" "Letter" "--print-media-type" "--margin-right" "0.0in" "--encoding" "UTF-8" "--margin-top" "0.5in" "--margin-bottom" "0.5in" "--margin-left" "0.0in" "--quiet" "-" "-" - (RuntimeError)
what am tried:
setting path
config.wkhtmltopdf = '/usr/local/bin/wkhtmltopdf '
installing dependencies
sudo aptitude install openssl build-essential xorg libssl-dev
Environment
Ubuntu 12.04 amd64
merb application
ruby 1.8.7
Problem sovled by changing the server port number
from
bundle exec merb -a thin #default port 4000
to
bundle exec merb -a thin -p 3000
and using the gem "wkhtmltopdf-binary"
Explanation
can sometimes find that the single threaded web server we use in development can cause a race condition. the browser is tieing up the one thread available, and begins a new web request to create the pdf files html, which causes a 2nd web request. Since your only web server thread is already in use, you can find this to hang.
To get around this, either run more threads. OR use another port for internal access, and have be the internal URL

Ocropus 4.4. crashes on Xubuntu 10.4

I have problems with Ocropus 4.4. (open source OCR). I installed Ocropus and neccessary libries following this script. Compilation/Installation goes without any problem.
However after successful installation of ocropus, I am not able to run any of ocropus-* commands. Ocropus-page and ocropus-hocr crash without giving any error meaningful message. I just get a cryptic killed after 2 minutes of processing.
ocropus-pages page_001.jpeg
[note] line recognizer: >
[note] *** 1 page_001.jpeg ***
Killed
I do not know where to start to fix it. Has anybody an idea where to start?
My machine is XUbuntu 10.4 64bits (run in VirtualBox) with 512MB of base memory.
I would try to convert your images to uncrompressed tiff before processing. I know that ocropus is working closely with tesseract and that tesseract handles 1bpp uncompressed tiffs the best.
Despite this being an old question I thought I'd post a solution / some debug tips as I experienced the same problem under the same scenario. The scenario being: Debian running under VirtualBox with 512MB RAM
In order to debug "Killed" messages you should look into /var/log for help. In my case kern.log contained:
debian kernel: [89675.791910] Out of memory: Kill process 13004
(ocropus-rtrain) score 806 or sacrifice child
debian kernel: [89675.791951] Killed process 13004 (ocropus-rtrain)
total-vm:800816kB, anon-rss:412424kB, file-rss:4kB
It's likely you need to increase the amount of resources assigned to the VM particularly if you're running some big fancy window manager in the background!

Resources