Skip to content

Conversation

@dentarg
Copy link
Member

@dentarg dentarg commented Feb 7, 2025

The result of git rebase upstream/main and fixing conflicts.

ecnelises and others added 24 commits April 12, 2024 08:31
The singular methods were deprecated long ago and finally removed in Ruby 3.2.0.
…hyphens "-" are not allowed in process names.

Several of the ports listed in the README have incorrectly not allowed hyphens to be present in process names.  I believe
it's because they took inspiration from this misleading comment at the top of the procfile.rb file.

[Haskell](https://github.com/fujimura/houseman/blob/f4a5da44a35a04c84694118c91894bda41efaaa0/src/Procfile/Parse.hs#L21)
[Go](https://github.com/mattn/goreman/blob/ebb9736b7c7f7f3425280ab69e1f7989fb34eadc/main.go#L103)
[Java](https://github.com/owenthereal/gaffer/blob/5704f4de1d438cc6527f7f4b5a439940607ccd54/src/main/java/gaffer/procfile/Procfile.java#L14)
The FakeFS spec helper already cleans up the filesystem after each test.
Also, that after helper is executed after FakeFS already deactivated
itself, so in some systems, that can cause the real /tmp to be removed
if the user running the tests has permissions to do so.
Includes logic to cause loading an empty Procfile to raise a
Foreman::Procfile::EmptyFileError.

Keeps existing logic/error message for `foreman check`, just rescues
this new error when doing so.
When (mistakenly) starting foreman with a empty Procfile, it ends up not
being possible to exit this process via a TERM signal due to the
following error:

    $ foreman start
    ERROR: Procfile does not exist.
    $ touch Procfile
    $ bin/foreman start
    ^Ccomparison of NilClass with 6 failed
    ./lib/foreman/engine/cli.rb:80:in `name_padding'
    ./lib/foreman/engine/cli.rb:85:in `pad_process_name'
    ./lib/foreman/engine/cli.rb:61:in `block in output'
    ./lib/foreman/engine/cli.rb:57:in `each'
    ./lib/foreman/engine/cli.rb:57:in `output'
    ./lib/foreman/engine.rb:335:in `block in output_with_mutex'
    ./lib/foreman/engine.rb:334:in `synchronize'
    ./lib/foreman/engine.rb:334:in `output_with_mutex'
    ./lib/foreman/engine.rb:340:in `system'
    ./lib/foreman/engine.rb:124:in `handle_interrupt'
    ./lib/foreman/engine.rb:104:in `handle_signal'
    ./lib/foreman/engine.rb:389:in `handle_signals'
    ./lib/foreman/engine.rb:412:in `block (2 levels) in watch_for_output'
    ./lib/foreman/engine.rb:409:in `loop'
    ./lib/foreman/engine.rb:409:in `block in watch_for_output'
    ^C^C^C^C^C^X^Z
    [1]+  Stopped                 bin/foreman start
    $ kill %1
    $ jobs
    [1]+  Running                 bin/foreman start &
    $ jobs
    [1]+  Running                 bin/foreman start &
    $ kill -9 %1
    [1]+  Killed: 9               bin/foreman start
    $ jobs

By adding a `.to_i`, this simply allows the `Engine::Cli#name_padding`
method to default to 6, allowing the rest of the shutdown process to
finish executing and exit the process gracefully.
Some processes are getting orphaned when running Foreman with JRuby.
Creating a new pgroup allows them all to be killed together.

I believe the issue is related to how JRuby handles `Dir.chdir` by
creating a shell process: `sh -c 'cd /chdir/target; ${command}'`. That
causes a second process to be created that won't get cleaned up by
killing the parent.

Co-authored-by: David Harsha <david.harsha@elastic.co>
Do not try to install latest RubyGems due to ruby/setup-ruby#422
Apparently the tests are sensitive to the output, like what happened in ruby/setup-ruby#420

Saw this option in ruby/rubygems#6187
@dentarg
Copy link
Member Author

dentarg commented Feb 7, 2025

Nope, not great

@dentarg dentarg closed this Feb 7, 2025
@dentarg dentarg deleted the rebase-upstream branch February 7, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants