File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ def self.save!(toggle_data)
66 Unleash . logger . debug "Will save toggles to disk now"
77
88 backup_file = Unleash . configuration . backup_file
9- backup_file_tmp = "#{ backup_file } .tmp"
9+ backup_file_tmp = "#{ backup_file } .tmp- #{ Process . pid } "
1010
1111 File . open ( backup_file_tmp , "w" ) do |file |
1212 file . write ( toggle_data )
Original file line number Diff line number Diff line change 6565 backup_file = Unleash . configuration . backup_file
6666 expect ( File . exist? ( backup_file ) ) . to eq ( true )
6767 end
68+
69+ # NOTE: this is a frequent issue with Puma (in clustered mode). See Unleash/unleash-ruby-sdk#108
70+ it "does not log errors due to concurrent forked processes" do
71+ log_file = -> ( pid ) { File . join ( Dir . tmpdir , "#{ pid } .log" ) }
72+ pids = Array . new ( 10 ) do
73+ fork do
74+ Unleash . logger = Logger . new ( log_file . call ( Process . pid ) )
75+ expect ( Unleash . logger ) . not_to receive ( :error )
76+ described_class . new engine
77+ end
78+ end
79+
80+ pids . each do |pid |
81+ Process . wait ( pid )
82+ process_status = $? # rubocop:disable Style/SpecialGlobalVars
83+ error_log_file = log_file . call ( pid )
84+ expect ( File . exist? ( error_log_file ) )
85+
86+ error_msg = "Process #{ pid } failed with errors:\n #{ File . read ( error_log_file ) . lines [ 1 ..] . join } "
87+ expect ( process_status ) . to be_success , error_msg
88+ end
89+ end
6890 end
6991 end
7092
You can’t perform that action at this time.
0 commit comments