rails logger not running as expected - ruby-on-rails

A legacy application (rails 4.2.10) was uploaded for staging purposes to a new server.
The log was populating at the start, but it all stopped at a certain point. Having to load a large database from google cloud, a browser was necessary as the link is to a page, not the object to download. VNC was installed, the file accessed and downloaded and VNC uninstalled shortly thereafter.
The last log entries are for malicious actors hitting the server targetting wordpress pages. wordpress is not installed. I cannot ascertain when they correspond to VNC installation/deactivation.
But no application page hits are registered past that point in time (quite a few days).
NGINX is the web server with the passenger nginx library. In development mode, puma 4.3.5 is invoked.
Is there any way to kickstart the Rails logger?

Related

Is one rails server per application?

I have two questions about rails server:
Do I have to start the server from within the application folder?
Is the server I started only for that application?
If they are true, this does not quite make sense to me, since why do I need to start multiple servers?
Or is there some kind of master configuration, so that one server can route to different applications? Is Capistrano for this purpose?
I'm going to assume you're talking about the rails server command, for running a local rails server to test your application, and that you're not talking about setting up a rails application on a remote server. Please mention if that is not the case.
Yes, you must execute rails server from within the root folder of your rails application.
Yes, the server you started is only for that application. It's a self-contained thing.
You should not need to start multiple servers. Even if you have multiple applications, you probably don't need to have more than one running at a time. So, you can shut down the rails server in one application (Ctrl-C) and then cd to your new application, and start a new rails server there with rails server.
If you do need to run two local rails applications at once, you can do so by running them on different ports. So, the first one, you can just execute rails server and it will make your site available at localhost:3000 (because port 3000 is the default port). The next one, you can specify a port other than 3000 - eg. rails server -p 3001 to get a rails app at localhost:3001.
Capistrano is for deploying your applications to a remote server, not for running them locally on your own computer. So, it is not relevant here. What you may be interested in is http://pow.cx/
Again, I've assumed you're talking about running your rails app locally on your own computer. If you're referring to deploying it to the internet on a server, then you can ignore this answer.

Setting up Rails on Hostmonster

I'm able to run rails s through ssh successfully and see the app start up just as it does on my own machine but I'm unable to access the app from the web. The app is directly under the home folder and I have a symbolic link pointing from public_html to the public folder of my rails app, just as this tutorial explains. I even tried setting up a subdomain and every other step in the tutorial to no avail. Any help would be highly appreciated.
You need an application server like Phusion Passenger, Unicorn or puma to run a Ruby app in a production environment. Typically, you'll integrate the application server into a web server's (Apache, nginx) environment.
I don't know about your hoster, but if you have root access, then you can probably use any of these application servers.
The built-in server you start by running rails server is only meant for testing purposes on your local machine. It has not been made with security, performance, stability or any other production-environment criteria in mind.

rails trying to trouble shoot latency on my development machine - where can I see the web server request log?

Im having a lot of latency running webrick on my development machine (localhost) .Anytime the browser makes a request, it takes the server about 8-9 seconds before it shows contents of the database, which contains just 34000 listings of text, output to the browser window.
I want to trouble shoot to find out whats happening.
Where should I start the process of troubleshooting?
I thought the first thing would be to monitor the web server logs to see requests.
But where can I find these on my development machine?
I know I can find the apache logs on my machine at
/var/log/apache2/access_log
but Rails doesnt run apache right? It runs webrick on port 3000
Please help.
When you run rails in development mode like:
rails s
..it usually runs WEBrick automatically as a foreground process and prints the type of information you're looking for to the console for each client request. You can check/tune some of the logging parameters by editing:
config/environments/development.rb
As WEBrick is the default web server, Apache has nothing to do with it unless you've configured your environment to do so. As you mentioned, the default port is 3000.
Newer versions of Rails can also log the the database query plan automatically for queries taking a long time to return.
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
You should also check your specific database for proper indexing based on the schema and queries you're trying to optimize.

How to make GlassFish web server use JRuby on Rails?

I installed Ubuntu, GlassFish web server, installed JRuby on Rails using GlassFish's admin tools, deployed my application from .war archive. The problem is only - when I attempt to run this web application nothing happens. GlassFish isn't listening on port 8080 as promised. The GlassFish administration web console listens on port 4848 and works fine. What to do to pair GlassFish and JRuby on Rails the correct way, remembering that it isn't a separate JRuby installation?
Update: it seems that this problem lies somewhere around access rights because I can deploy an application through
sudo ./asadmin deploy
but can not do the same through web console. The output is as if the application has been deployed, without any error messages (web interface shows the presence of application, domain folder contains my application's file/folder structure), but something in server's internals isn't bound to application.
I didn't think much and applied quick and dirty solution: set "777" access rights to /home/glassfish and all its contents. It helped.

How can I start up a ruby server script when I start up my rails app?

I'd like for a ruby server script that lives in my rails app root folder to accept connections from clients (the clients are not browsers--not that this really matters i guess) and update the db of my rails app while my rails app is running. Therefore, I'd like for it to be told somehow to start running whenever my web server starts serving up my rails app and stop running whenever my web server stops serving my rails app. How can I do this? Is this as simple as putting the name/path of my ruby server script somewhere?
You should look into Foreman, a gem specifically for launching multiple processes in your server environment.

Resources