Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting process name #56

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/midi-smtp-server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,21 @@ def workers?
# before joining the server threads, check and wait optionally a few seconds
# to let the service(s) come up
def join(sleep_seconds_before_join: 1)
# set process name
$0 = "[MidiSmtp] #{ARGV.join(' ')} (main)"
# check already existing TCPServers
return if @tcp_servers.empty?
# check number of processes to pre-fork

if pre_fork?
# create a number of pre-fork processes and attach and join threads within workers
idx = 0
@pre_fork.times do
# append worker pid to list of workers
@workers << fork do
# set forked process name
$0 = "[MidiSmtp] #{ARGV.join(' ')} (worker #{idx})"
idx += 1
# set state for a forked process
@is_forked = true
# just attach and join the threads to forked worker process
Expand Down
4 changes: 2 additions & 2 deletions test/integration/io_waitreadable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def io_waitreadable_sleep
def test_slow_io_waitreadable_sleep
# This test hits IO::WaitReadable exception multiple times
# For that, this test must run longer than 1 second
assert measure_io_waitreadable_sleep > 1
assert_operator measure_io_waitreadable_sleep, :>, 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @iuri-gg,
thanks for posting that.
I have to check all the tests for styleguide puposes.

end

end
Expand All @@ -67,7 +67,7 @@ def io_waitreadable_sleep
def test_fast_io_waitreadable_sleep
# This test hits IO::WaitReadable exception multiple times
# For that, this test must run longer than 1 second
assert measure_io_waitreadable_sleep < 1
assert_operator measure_io_waitreadable_sleep, :<, 1
end

end