[ruby-talk:444361] Weird Rails behaviour when dockerised

I have this old app, Ruby 1.8.7, Rails 2.3.2, that runs on Ubuntu 1404. It
is old, rock solid and undocumented. We are going to rewrite it but at
present we have dockerised it as is because we feared that the host that
runs it (also very old) may simply die

So we build a container around 14.04, compiled ruby 1.8.7 and installed the
necessary gems. Fired it up and pointed the load balancer at it. It is
working just fine and we can finally breath. To be clear the container only
contains the Rails app and the unicorn_rails application server, the rest
of the stack, Nginx and the database, live in their own 22.04 containers

Now the odd part, despite the application running in production mode it
logs like it is in development mode and the logs are bloated with all the
database activity. The log files are a minimum 2/3 database logging. The
old installation doesn't do this

For the life of me I can not work out how to stop the database logging

Any ideas?

Hello, Peter! I suggest to explore environment variables on old machine.
Anyway you can setup log level for you application: Ruby on Rails Guides: Configuring Rails Applications

Another possible source of the problem is that you application runs in development mode instead of production.

30.10.2023 17:16, Peter Hickman via ruby-talk пишет:

···

I have this old app, Ruby 1.8.7, Rails 2.3.2, that runs on Ubuntu 1404. It is old, rock solid and undocumented. We are going to rewrite it but at present we have dockerised it as is because we feared that the host that runs it (also very old) may simply die

So we build a container around 14.04, compiled ruby 1.8.7 and installed the necessary gems. Fired it up and pointed the load balancer at it. It is working just fine and we can finally breath. To be clear the container only contains the Rails app and the unicorn_rails application server, the rest of the stack, Nginx and the database, live in their own 22.04 containers

Now the odd part, despite the application running in production mode it logs like it is in development mode and the logs are bloated with all the database activity. The log files are a minimum 2/3 database logging. The old installation doesn't do this

For the life of me I can not work out how to stop the database logging

Any ideas?

  ______________________________________________
  ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
  To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
  ruby-talk info -- Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org

______________________________________________
ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
ruby-talk info -- Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org

As far as I can tell it is in production, it uses the
environments/production.rb file (I can tell because there is a side effect
that the other environments do not have) and even if it is forced
in environment.rb, ENV['RAILS_ENV'] = 'production', I still get database
logging

···

On Mon, 30 Oct 2023 at 14:44, Anton Shchankin via ruby-talk < ruby-talk@ml.ruby-lang.org> wrote:

Hello, Peter! I suggest to explore environment variables on old machine.
Anyway you can setup log level for you application:
Ruby on Rails Guides: Configuring Rails Applications

Another possible source of the problem is that you application runs in
development mode instead of production.

30.10.2023 17:16, Peter Hickman via ruby-talk пишет:
> I have this old app, Ruby 1.8.7, Rails 2.3.2, that runs on Ubuntu
> 1404. It is old, rock solid and undocumented. We are going to rewrite
> it but at present we have dockerised it as is because we feared that
> the host that runs it (also very old) may simply die
>
> So we build a container around 14.04, compiled ruby 1.8.7 and
> installed the necessary gems. Fired it up and pointed the load
> balancer at it. It is working just fine and we can finally breath. To
> be clear the container only contains the Rails app and the
> unicorn_rails application server, the rest of the stack, Nginx and the
> database, live in their own 22.04 containers
>
> Now the odd part, despite the application running in production mode
> it logs like it is in development mode and the logs are bloated with
> all the database activity. The log files are a minimum 2/3 database
> logging. The old installation doesn't do this
>
> For the life of me I can not work out how to stop the database logging
>
> Any ideas?
>
>
> ______________________________________________
> ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
> To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
> ruby-talk info --
Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org
______________________________________________
ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
ruby-talk info --
Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org

Add to environments/production.rb:

config.log_level =:warn

30.10.2023 18:29, Peter Hickman пишет:

···

As far as I can tell it is in production, it uses the environments/production.rb file (I can tell because there is a side effect that the other environments do not have) and even if it is forced in environment.rb, ENV['RAILS_ENV'] = 'production', I still get database logging

On Mon, 30 Oct 2023 at 14:44, Anton Shchankin via ruby-talk > <ruby-talk@ml.ruby-lang.org> wrote:

    Hello, Peter! I suggest to explore environment variables on old
    machine.
    Anyway you can setup log level for you application:
    Ruby on Rails Guides: Configuring Rails Applications

    Another possible source of the problem is that you application
    runs in
    development mode instead of production.

    30.10.2023 17:16, Peter Hickman via ruby-talk пишет:
    > I have this old app, Ruby 1.8.7, Rails 2.3.2, that runs on Ubuntu
    > 1404. It is old, rock solid and undocumented. We are going to
    rewrite
    > it but at present we have dockerised it as is because we feared
    that
    > the host that runs it (also very old) may simply die
    >
    > So we build a container around 14.04, compiled ruby 1.8.7 and
    > installed the necessary gems. Fired it up and pointed the load
    > balancer at it. It is working just fine and we can finally
    breath. To
    > be clear the container only contains the Rails app and the
    > unicorn_rails application server, the rest of the stack, Nginx
    and the
    > database, live in their own 22.04 containers
    >
    > Now the odd part, despite the application running in production
    mode
    > it logs like it is in development mode and the logs are bloated
    with
    > all the database activity. The log files are a minimum 2/3 database
    > logging. The old installation doesn't do this
    >
    > For the life of me I can not work out how to stop the database
    logging
    >
    > Any ideas?
    >
    > ______________________________________________
    > ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
    > To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
    > ruby-talk info --
    Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org
     ______________________________________________
     ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
     To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
     ruby-talk info --
    Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org

Ok, slapping 'ActiveRecord::Base.logger = nil' at the end of environment.rb
seems to do the trick. Doesn't answer why it is behaqving like this but I
am happier having daily logs below a Gb

···

On Mon, 30 Oct 2023 at 15:29, Peter Hickman <peterhickman386@googlemail.com> wrote:

As far as I can tell it is in production, it uses the
environments/production.rb file (I can tell because there is a side effect
that the other environments do not have) and even if it is forced
in environment.rb, ENV['RAILS_ENV'] = 'production', I still get database
logging

On Mon, 30 Oct 2023 at 14:44, Anton Shchankin via ruby-talk < > ruby-talk@ml.ruby-lang.org> wrote:

Hello, Peter! I suggest to explore environment variables on old machine.
Anyway you can setup log level for you application:
Ruby on Rails Guides: Configuring Rails Applications

Another possible source of the problem is that you application runs in
development mode instead of production.

30.10.2023 17:16, Peter Hickman via ruby-talk пишет:
> I have this old app, Ruby 1.8.7, Rails 2.3.2, that runs on Ubuntu
> 1404. It is old, rock solid and undocumented. We are going to rewrite
> it but at present we have dockerised it as is because we feared that
> the host that runs it (also very old) may simply die
>
> So we build a container around 14.04, compiled ruby 1.8.7 and
> installed the necessary gems. Fired it up and pointed the load
> balancer at it. It is working just fine and we can finally breath. To
> be clear the container only contains the Rails app and the
> unicorn_rails application server, the rest of the stack, Nginx and the
> database, live in their own 22.04 containers
>
> Now the odd part, despite the application running in production mode
> it logs like it is in development mode and the logs are bloated with
> all the database activity. The log files are a minimum 2/3 database
> logging. The old installation doesn't do this
>
> For the life of me I can not work out how to stop the database logging
>
> Any ideas?
>
>
> ______________________________________________
> ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
> To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
> ruby-talk info --
Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org
______________________________________________
ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
ruby-talk info --
Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org

Any chance that gem code may have been edited in-place to alter the
database logging on the old server?

I know that's something I should never do, but I have done it a time
or few. :slight_smile:

···

On Mon, Oct 30, 2023, at 10:16 AM, Peter Hickman via ruby-talk wrote:

So we build a container around 14.04, compiled ruby 1.8.7 and installed
the necessary gems. Fired it up and pointed the load balancer at it. It
is working just fine and we can finally breath. To be clear the container
only contains the Rails app and the unicorn_rails application server,
the rest of the stack, Nginx and the database, live in their own 22.04
containers

Now the odd part, despite the application running in production mode it
logs like it is in development mode and the logs are bloated with all the
database activity. The log files are a minimum 2/3 database logging. The
old installation doesn't do this

______________________________________________
ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
ruby-talk info -- Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org

There is one hack, the memcached gem to get it to accept 4Mb key size. The
memcached server can handle it but the old gem acted as a gatekeeper on
this value. So a sed script changes the value. But that is the only one

···

On Mon, 30 Oct 2023 at 15:56, Frank J. Cameron via ruby-talk < ruby-talk@ml.ruby-lang.org> wrote:

On Mon, Oct 30, 2023, at 10:16 AM, Peter Hickman via ruby-talk wrote:
> So we build a container around 14.04, compiled ruby 1.8.7 and installed
> the necessary gems. Fired it up and pointed the load balancer at it. It
> is working just fine and we can finally breath. To be clear the container
> only contains the Rails app and the unicorn_rails application server,
> the rest of the stack, Nginx and the database, live in their own 22.04
> containers
>
> Now the odd part, despite the application running in production mode it
> logs like it is in development mode and the logs are bloated with all the
> database activity. The log files are a minimum 2/3 database logging. The
> old installation doesn't do this

Any chance that gem code may have been edited in-place to alter the
database logging on the old server?

I know that's something I should never do, but I have done it a time
or few. :slight_smile:
______________________________________________
ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
ruby-talk info --
Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org