Ruby system command fails Apache(Passenger) - ruby-on-rails

Attempting to build statistics into a side project via Rserve- Everything works in testing and rails console but in production under:
apache(passenger), Rails 4, ruby-2.3.0.
the commands work in the rails console on the production box and I've confirmed that:
/bin/R is in the rails production (apache) path.
system "R CMD Rserve" works as expected in rails console on production host with production environment loaded
In production running Apache(Passenger):
system "R CMD Rserve" returns false
$?.inspect returns -> Process::Status: pid 11144 exit 2
The exit status 2 is throwing me off because it indicated a missing keyword or command, or permission problem.
Anybody run into this? I think the issue is in passenger but the limited output is making this hard to debug..

Related

GIT Bash MingW32 Rails Console - Text input fails after exit and restart console

I installed Rails and I am having issues with the Rails console in Git Bash (MINGW32).
The first time I launch the Rails console using rails c, I can input text and everything works as expected. However if I exit the rails console using Ctrl-C then start the Rails console again, the text input is wrong.
In the example, I started the Rails console, input "Zombie.first", got the expected response, exited the console, started it again, entered "Zombie.first" again, but the console actually executes "Zoiefr". Any text I enter after this will be similarly affected until restarting git bash.
I performed the RailsInstaller install on two different Windows machines with the same result.
Does anybody have suggestions for how to fix it, or for other Windows development environments to try?

Shell commands fail in Rails in production mode

I have deployed on a VPS a Rails 4 application that executes shell command depending on the tasks. The app runs on Nginx with Passenger.
The situation I am having is that none of the shell commands work. After a bit of debugging, I've noticed that every command returns a "not found" error message.
For example:
out = %x[date 2>&1] # outputs 'sh: 1: date: not found\n'
why is this happening? is there some configuration setting I should set to allow shell commands in production mode? I am quite new to rails so I'm not really sure what could be causing this.
UPDATE:
Here's a bit more information, when querying from rails whoami, i get www-data, if I print the $PATH I get /usr/local/lib/ruby/gems/2.1.0/bin but then if in the command line execute sudo -u www-data printenv PATH the result is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin... Does this makes any sense?

Where can I find developer output from Rails application deployed to Torquebox

I have a JRuby on Rails application, which is usually deployed as war to Tomcat. In development mode we use either WEBrick or trinidad (usually first). Now we are considering using Toquebox.
I was able to deploy app using Torquebox, but I wonder where can I find development logs (things like request/response details, executed SQL queries etc). I got used to that stuff. JBoss'es console, boot.log and server.log don't contain those - only torquebox specific logging.
Thanks
When you are currently in your applications directory, use
$ less log/development.log
For every enviorement: env
$ less log/<env>.log
For following it (as it appends) use:
$ tail -f log/<env>.log

Can't Get Mongrel_Service Gem to Start Mongrel as a Windows Service

I’m more or less a newb to Ruby on Rails, but I’ve been tasked with debuging a Rails app that guy that’s no longer around wrote. The app is running on a manchine using:
• Windows XP Professional
• Apache 2.2
• Rails 2.3.8
• mongrel (1.1.5 x86-mingw32)
• mongrel_service (0.3.4 i386-mswin32)
I copied the app from the server and did some debugging on it on my personal machine. I just setup a Git repository on my personal machine and cloned it back over to the server. Everything seems to be working great except mongrel_service doesn’t work anymore. Each time I try to start the service from Windows “Services” tool I get this error:
The MYAPP_Mongrel_As_Service service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service
I tried removing the service with:
C:\MyApp>mongrel_rails service::remove --name MYAPP_Mongrel_As_Service
Stopping MYAPP_Mongrel_As_Service if running...
MYAPP_Mongrel_As_Service service removed
and reinstalling it with:
C:\MyApp>mongrel_rails service::install --name MYAPP_Mongrel_As_Service -c "C:\MyApp" --port 3001 --env
ironment production --address localhost --log "log\mongrel_as_service.log" --pid "tmp\pids\mongrel_a
s_service.pid"
MYAPP_Mongrel_As_Service service created.
But no matter how many times I try, or what options I use, I can’t get the service to run. What’s weird is that I can get mongrel to startup by itself just fine.
C:\MyApp>mongrel_rails start -c c:\MyApp --port 3001 --environment production --address localhost --
g "c:\MyApp\log\mongrel_as_service.log" --pid "C:\MyApp\tmp\pids\mongrel_as_service.pid"
** Starting Mongrel listening at localhost:3001
** Starting Rails with production environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready. INT => stop (no restart).
** Mongrel 1.1.5 available at localhost:3001
** Use CTRL-C to stop.
It just won’t work when I try to start it as a service. I've done a lot of googling on the subject, but I can't find anything to fix the problem. It's odd that it was working before but now it doesn't. There must be something wrong with my service::install line because I can't get the original unedited Rails app to work with mongrel_as_service either.
I figured it out. It turns out that the log file for mongrel_service didn't exist on my file. To fix the problem, I just made a blank text file and renamed it to the name of my log file. It worked like a charm. It's odd that mongrel_service doesn't make it's own log file if it can't detected it, but oh well.

Why would running a Rails app as a WEBrick server work, but installing it as a Mongrel service would not?

Yet another newbie RoR question from me.
I started banging my head against a wall last night when I simply could not get my Rails app to display in my browser after installing it as a Mongrel service.
I installed it using a command like this (from the app's root directory):
mongrel_rails service::install -N MyAppName -e development -p 3000
This set up the Windows service and everything seemed to be just fine. I could start/stop the service and saw no errors in the logs. Then navigating to localhost:3000 in my browser, I was greeted with a variety of errors, none Rails-specific (all along the lines of "Could not connect to server" or the like). Consulting the log at this point revealed no obvious problems.
I could not for the life of me figure out how to get this to work. So, out of exasperation, I tried simply running the app on WEBrick instead:
ruby script/server webrick -p 3000
When I did this, my app ran perfectly! Opening my browser to localhost:3000 now displayed my front page as expected.
I should note that I have used Mongrel successfully for other apps on my local machine.
So what app-specific characteristics could be responsible for WEBrick working where Mongrel doesn't?
Just some ideas to try:
Add -c param with full path to application:
-c "C:\xxx\yyy\zzz"
Check if system-wide PATH environment variable contains ruby bin directory - maybe just user's PATH is set.
Switch service to run as your user.

Resources