From 35d557c635a5a144873f62c6a781edc1d6ca87ea Mon Sep 17 00:00:00 2001 From: Iuri G <289754+iuri-gg@users.noreply.github.com> Date: Sun, 19 Nov 2023 21:29:43 -0600 Subject: [PATCH] * Add support for setting process name --- lib/midi-smtp-server.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/midi-smtp-server.rb b/lib/midi-smtp-server.rb index b12dc3d..1bbbacd 100644 --- a/lib/midi-smtp-server.rb +++ b/lib/midi-smtp-server.rb @@ -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