Skip to content

Commit

Permalink
* Add support for setting process name
Browse files Browse the repository at this point in the history
  • Loading branch information
iuri-gg committed Nov 20, 2023
1 parent c23736c commit 35d557c
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit 35d557c

Please sign in to comment.