rubygems / gemstash

A RubyGems.org cache and private gem server
MIT License
752 stars 120 forks source link

fix: Define 'sync' method on logger for compatibility with Puma > 5 #355

Closed ball-hayden closed 1 year ago

ball-hayden commented 1 year ago

Description:

Since at least https://github.com/puma/puma/commit/a284179d9d13c15e7b1f03332c3d2591bcd7d77b, puma has required that the logger respond to a sync method.

This implements the above method. With this change, Gemstash will start with Puma 6.3.1 when the --no-daemonize flag is passed.

It might also be worth changing the daemonize default to false - Puma versions greater than ~5.0 do not support demonizing (without https://github.com/kigster/puma-daemon or alternative)?


Tasks:

I will abide by the code of conduct.

n-rodriguez commented 1 year ago

👍

The error :

nonroot@b098cdf13b8a:/app$ bin/gemstash start --no-daemonize --config-file /app/config.yml.erb
Starting gemstash!
[2023-09-03 19:47:54 +0000] - INFO - [118] Puma starting in cluster mode...
/app/vendor/bundle/ruby/3.2.0/gems/puma-6.3.1/lib/puma/log_writer.rb:80:in `internal_write': undefined method `sync' for #<Gemstash::Logging::StreamLogger:0x00007f1943db9e90 @level=1> (NoMethodError)

          @stdout.flush unless @stdout.sync
                                      ^^^^^
    from /app/vendor/bundle/ruby/3.2.0/gems/puma-6.3.1/lib/puma/log_writer.rb:66:in `log'
    from /app/vendor/bundle/ruby/3.2.0/gems/puma-6.3.1/lib/puma/runner.rb:45:in `log'
    from /app/vendor/bundle/ruby/3.2.0/gems/puma-6.3.1/lib/puma/runner.rb:107:in `output_header'
    from /app/vendor/bundle/ruby/3.2.0/gems/puma-6.3.1/lib/puma/cluster.rb:341:in `run'
    from /app/vendor/bundle/ruby/3.2.0/gems/puma-6.3.1/lib/puma/launcher.rb:194:in `run'
    from /app/vendor/bundle/ruby/3.2.0/gems/puma-6.3.1/lib/puma/cli.rb:75:in `run'
    from /app/vendor/bundle/ruby/3.2.0/gems/gemstash-2.3.0/lib/gemstash/cli/start.rb:16:in `run'
    from /app/vendor/bundle/ruby/3.2.0/gems/gemstash-2.3.0/lib/gemstash/cli.rb:79:in `start'
    from /app/vendor/bundle/ruby/3.2.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
    from /app/vendor/bundle/ruby/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
    from /app/vendor/bundle/ruby/3.2.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
    from /app/vendor/bundle/ruby/3.2.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
    from /app/vendor/bundle/ruby/3.2.0/gems/gemstash-2.3.0/lib/gemstash/cli.rb:34:in `start'
    from /app/vendor/bundle/ruby/3.2.0/gems/gemstash-2.3.0/exe/gemstash:6:in `<top (required)>'
    from bin/gemstash:27:in `load'
    from bin/gemstash:27:in `<main>'
olleolleolle commented 1 year ago

OK, so the CI failure is a little tricky, but has nothing to do with this change.

With JRuby 9.4, we got:

In Gemfile:
  gemstash was resolved to 2.3.0, which depends on
    sequel was resolved to 5.72.0, which depends on
      bigdecimal
olleolleolle commented 1 year ago

Merging this compatibility-with-the-webserver-we-use change, and logging an Issue about the JRuby 9.4 not building correctly. It did build correctly just the other day.

ball-hayden commented 1 year ago

Thanks @olleolleolle