Ruby Daemons will not start - ruby

I am using the ruby daemons gem to create a custom daemon for my rails project. The only problem is that when I try to start the daemons ruby lib/daemons/test_ctl start that it fails and will not start. The log file has this output.
# Logfile created on Wed Oct 22 16:14:23 +0000 2008 by /
*** below you find the most recent exception thrown, this will be likely (but not certainly) the exception that made the application exit abnormally \*\*\*
# MissingSourceFile: no such file to load -- utf8proc_native
*** below you find all exception objects found in memory, some of them may have been thrown in your application, others may just be in memory because they are standard exceptions ***
# NoMemoryError: failed to allocate memory>
# SystemStackError: stack level too deep>
# fatal: exception reentered>
# LoadError: no such file to load -- daemons>
# LoadError: no such file to load -- active_support>
# MissingSourceFile: no such file to load -- lib/string>
# MissingSourceFile: no such file to load -- utf8proc_native>
It even happens when I generate a daemon (from the rails plugin) and try to run it. Does anybody know how to fix this problem?

OK, I actually found the answer to this problem. I require two custom files in the config/environment.rb. I used relative path names and because the daemons are executed in the rails main directory it could not find these two files. after making them absolute path it fixed the problem.

I just spent 30 minutes trying to solve a similar error when trying to get daemons plugin working:
LoadError: no such file to load -- active_support
For some reason, it wasn't finding active_support lib, even though it was installed. (Perhaps due to me having frozen rails).
In my case, the solution to this was to use the absolute path for active_support in my
ctl file (eg lib/daemons/mailer_ctl).
I needed to change line 5 from:
require 'active_support'
to
require './vendor/rails/activesupport/lib/active_support.rb'

Related

Apartment-sidekiq giving issues with ActiveStorage::AnalyzeJob issue

I integrated apartment-sidekiq with my multi tenant rails app, but its logging following issue in sidekiq.log. Custom emails are perfectly handled but seems its issue with active_storage job, why is it trying to find the directory which doesn't exists? I manually checked the directory and its not there, (sometimes, worker try to find a record before it is saved, seems thats not the case here), Is it trying to find a path in other tenant?.
I am using Rails 5.2, ruby 2.3.1
2019-08-15T06:58:14.857Z 12629 TID-137g5x ActiveStorage::AnalyzeJob JID-2555d469bbee6a7b618446d3 INFO: start
2019-08-15T06:58:15.968Z 12629 TID-137g5x ActiveStorage::AnalyzeJob JID-2555d469bbee6a7b618446d3 INFO: fail: 1.121 sec
2019-08-15T06:58:15.973Z 12629 TID-137g5x WARN: {"context":"Job raised exception","job":{"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped":"ActiveStorage::AnalyzeJob","queue":"default","args":[{"job_class":"ActiveStorage::AnalyzeJob","job_id":"30a39eff-b93f-41b3-8d0f-aae6e070c4c7","provider_job_id":null,"queue_name":"default","priority":null,"arguments":[{"_aj_globalid":"gid://flap/ActiveStorage::Blob/5"}],"executions":0,"locale":"en"}],"retry":true,"jid":"2555d469bbee6a7b618446d3","created_at":1565789876.7082293,"apartment":"tenant_name","enqueued_at":1565852294.8079991,"error_message":"No such file or directory # rb_sysopen - /abc/flapp-cap/releases/20190814172709/storage/Ma/xS/MaxSwEqwUMV5WFG35Kz7qMLy","error_class":"Errno::ENOENT","failed_at":1565789876.718125,"retry_count":12,"retried_at":1565831257.7109427},"jobstr":"{\"class\":\"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper\",\"wrapped\":\"ActiveStorage::AnalyzeJob\",\"queue\":\"default\",\"args\":[{\"job_class\":\"ActiveStorage::AnalyzeJob\",\"job_id\":\"30a39eff-b93f-41b3-8d0f-aae6e070c4c7\",\"provider_job_id\":null,\"queue_name\":\"default\",\"priority\":null,\"arguments\":[{\"_aj_globalid\":\"gid://flapp/ActiveStorage::Blob/5\"}],\"executions\":0,\"locale\":\"en\"}],\"retry\":true,\"jid\":\"2555d469bbee6a7b618446d3\",\"created_at\":1565789876.7082293,\"apartment\":\"tenant_name\",\"enqueued_at\":1565852294.8079991,\"error_message\":\"No such file or directory # rb_sysopen - /abc/flapp-bc/cap/releases/20190814172709/storage/Ma/xS/MaxSwEqwUMV5WFG35Kz7qMLy\",\"error_class\":\"Errno::ENOENT\",\"failed_at\":1565789876.718125,\"retry_count\":12,\"retried_at\":1565831257.7109427}"}
2019-08-15T06:58:15.973Z 12629 TID-137g5x WARN: Errno::ENOENT: No such file or directory # rb_sysopen - /abc/flapp/storage/cW/J7/cWJ7vKtzyfDNMHmtYV8ckErR

Intermittently breaking tests in my hand-rolled Sinatra app. Related to file processing?

Summary: After adding logic to save user account data, my code seems to work fine and sometimes all my (many) tests pass. But sometimes they fail seemingly randomly, with /tmp test files not being deleted during testing.
In my hand-rolled Ruby/Sinatra "to do list" program, I added user accounts and can now save data to user files (.yml format) as well as tmp files for people who aren't logged in. Yay!
As far as I can tell, the code works fine. All tests pass...but only sometimes. Sometimes, the tests related to my new file processing methods fail. Here's a sample:
# Running:
....EF..........................
Finished in 3.930466s, 8.1415 runs/s, 53.1744 assertions/s.
1) Error:
ToDoTest#test_post_newtask:
Errno::EACCES: Permission denied # unlink_internal - tmp/1.yml
C:/Users/user/Dropbox/_Programming/Ruby/learning_projects/todo/test/test_todo.rb:404:in `delete'
C:/Users/user/Dropbox/_Programming/Ruby/learning_projects/todo/test/test_todo.rb:404:in `block (2 levels) in teardown'
C:/Users/user/Dropbox/_Programming/Ruby/learning_projects/todo/test/test_todo.rb:404:in `each'
C:/Users/user/Dropbox/_Programming/Ruby/learning_projects/todo/test/test_todo.rb:404:in `block in teardown'
2) Failure:
ToDoTest#test_get_deleted [C:/Users/user/Dropbox/_Programming/Ruby/learning_projects/todo/test/test_todo.rb:167]:
Expected false to be truthy.
32 runs, 209 assertions, 1 failures, 1 errors, 0 skips
rake aborted!
Command failed with status (1): [ruby -I"lib" -I"C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib" "C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/test_task.rb" "test/test_task_store.rb" "test/test_todo.rb" "test/test_todo_helpers.rb" "test/test_users.rb" ]
Tasks: TOP => default => test
(See full trace by running task with --trace)
This is only a sample, because sometimes many more tests fail or have errors. It's weirdly random. I noticed that my tests, which result in a lot /tmp files being made and deleted very rapidly, sometimes failed to delete some files, and as a result some would be left behind. If I reran my tests when there were some undeleted files in /tmp, there would be even more (again, random) errors.
One common error I saw, which I never saw before adding the new file processing commands, is this one: Errno::EACCES: Permission denied # unlink_internal. I looked this up on SO but there seems to be only (irrelevant-seeming) Rails stuff. This is a Sinatra program running on Windows. So could I replicate the tests in my Ubuntu VM? Yes I could. Precisely the same sort of error pattern.
Anyway, I suspected that system commands were not finishing before execution continued. But apparently not. I tried putting "sleep 2" after all my system commands, and I still got a random failing test and cruft left in /tmp. I also tried using threads, which I have never used before, like this:
delr = Thread.new do
File.delete(#store.path) # seems to help to add this here...
end
delr.join
But that didn't help.
One other thing...I'm teaching myself and this is probably not the way it's supposed to be done, but...all of my get methods are preceded by a check of my session[:id] variable to see if the user is logged in, and to see if the correct datafile is loaded. I don't know if that's relevant but it might be.
Any ideas on what the problem could be or how to fix it?

Jekyll Error - "serve" only works once

Started working on an update to my website. It was working fine the other day but now I get an error.
I generally type on CMD (i'm on Windows 10) "bundle exec Jekyll serve --watch" and the server goes. I can edit and save and its all reflected in browser upon refresh.
Now I can do this, but if I make one change to any file it works. Do another change and I get an error. I have to terminate and type again.
Below is the error:
D:\Tristen Grant\Documents\GitHub\portfolio>bundle exec jekyll serve --watch
DL is deprecated, please use Fiddle
Configuration file: D:/Tristen Grant/Documents/GitHub/portfolio/_config.yml
Source: D:/Tristen Grant/Documents/GitHub/portfolio
Destination: D:/Tristen Grant/Documents/GitHub/portfolio/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 0.595 seconds.
Auto-regeneration: enabled for 'D:/Tristen Grant/Documents/GitHub/portfolio'
Configuration file: D:/Tristen Grant/Documents/GitHub/portfolio/_config.yml
Server address: http://127.0.0.1:3000//
Server running... press ctrl-c to stop.
Regenerating: 1 file(s) changed at 2016-09-06 16:16:28 ...done in 0.521498 seconds.
Regenerating: 1 file(s) changed at 2016-09-06 16:16:30 ...error:
Error: No such file or directory - git rev-parse HEAD
Error: Run jekyll build --trace for more information.
[2016-09-06 16:19:35] ERROR Errno::ENOTSOCK: An operation was attempted on something that is not a socket.
C:/Ruby21-x64/lib/ruby/2.1.0/webrick/server.rb:170:in `select'
Terminate batch job (Y/N)? y
Terminate batch job (Y/N)? y
I'm using Ruby 2.1.5 64 bit version. RubyDevKit, Sass, Bourbon.
Any ideas how to fix this? I don't know much about Jekyll or ruby. Just starting out.
I also get this error in CMD. You should have github's desktop app installed; try running the same commands from the GitShell you get with that app.
For me that works, it saves me the trouble of installing git globally on Windows and setting it up.

Why does Phalcon 2 raise "undefined symbol: php_pdo_get_dbh_ce in Unknown on line 0" warning?

When I installed Phalcon 2.0.13 according to the https://docs.phalconphp.com/en/latest/reference/install.html description and I wanted to launch my test script then I got the following error (literally it is just a warning but it causes Phalcon not to be loaded which causes errors):
{
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/phalcon.so' - /usr/lib/php/20131226/phalcon.so: undefined symbol: php_pdo_get_dbh_ce in Unknown on line 0
}
What is this symptom cased by and how could I get rid of it?
After struggling a lot, I managed to solve the problem. The {extension=phalcon.so} line should be put NOT in php.ini. Much rather, you should create a /etc/php/5.6/cli/conf.d/30-phalcon.ini file containing {extension=phalcon.so}.
The reason is that this way you can guarantee that the processing order of the ini files is appropriate.
If you want to use Phantom not just in cli but in apache module as well then copy the ini file in the corresponding directory too.
(The directory names can be different in your system.)

cannot load such file -- rubygems/defaults/ruby error?

I tried to import my Vendor's MIBs using import.rb,
i have put my .mib file(s) into a directory called mib .
/snmp-1.2.0# ls ./mib/
cpq54nn.mib cpqdmii.mib cpqhost.mib cpql2mgt.mib cpqrack.mib cpqservice.mib cpqstsys.mib
.......
OS has the libsmi package installed:
libsmi2-dev install
libsmi2ldbl:amd64 install
I got the err msg as below ,
snmp-1.2.0$ ruby -d import.rb mibs/
Exception LoadError' at /usr/lib/ruby/2.1.0/rubygems.rb:1203 - cannot load such file -- rubygems/defaults/ruby
ExceptionNameError' at /usr/lib/ruby/2.1.0/psych/class_loader.rb:67 - uninitialized constant BigDecimal
Exception NameError' at /usr/lib/ruby/2.1.0/psych/class_loader.rb:67 - uninitialized constant DateTime
ExceptionNameError' at /usr/lib/ruby/2.1.0/psych/core_ext.rb:16 - methodto_yaml' not defined in Object
ExceptionNameError' at /usr/lib/ruby/2.1.0/psych/core_ext.rb:29 - methodyaml_as' not defined in Module
ExceptionNameError' at /usr/lib/ruby/2.1.0/psych/deprecated.rb:81 - undefined methodto_yaml_properties' for classObject'
I truly appreciate ... your help in resolving the problem.
If you're loading in a YAML file that has frozen classes that aren't defined you'll have to load those prior to deserializing this file.
I don't know what you'll encounter, it just runs until it stumbles over the first thing, but if you need DateTime then require 'date' might fix that. Whatever class is missing you need to do the same thing, track down where it's defined and require it prior to the YAML.load part.

Resources