File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ def self.save!(toggle_data)
6
6
Unleash . logger . debug "Will save toggles to disk now"
7
7
8
8
backup_file = Unleash . configuration . backup_file
9
- backup_file_tmp = "#{ backup_file } .tmp"
9
+ backup_file_tmp = "#{ backup_file } .tmp- #{ Process . pid } "
10
10
11
11
File . open ( backup_file_tmp , "w" ) do |file |
12
12
file . write ( toggle_data )
Original file line number Diff line number Diff line change 65
65
backup_file = Unleash . configuration . backup_file
66
66
expect ( File . exist? ( backup_file ) ) . to eq ( true )
67
67
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
+ skip 'Fork not supported on current platform' unless Process . respond_to? ( :fork )
72
+
73
+ log_file = -> ( pid ) { File . join ( Dir . tmpdir , "#{ pid } .log" ) }
74
+ pids = Array . new ( 10 ) do
75
+ fork do
76
+ Unleash . logger = Logger . new ( log_file . call ( Process . pid ) )
77
+ expect ( Unleash . logger ) . not_to receive ( :error )
78
+ described_class . new engine
79
+ end
80
+ end
81
+
82
+ pids . each do |pid |
83
+ Process . wait ( pid )
84
+ process_status = $? # rubocop:disable Style/SpecialGlobalVars
85
+ error_log_file = log_file . call ( pid )
86
+ expect ( File . exist? ( error_log_file ) )
87
+
88
+ error_msg = "Process #{ pid } failed with errors:\n #{ File . read ( error_log_file ) . lines [ 1 ..] . join } "
89
+ expect ( process_status ) . to be_success , error_msg
90
+ end
91
+ end
68
92
end
69
93
end
70
94
You can’t perform that action at this time.
0 commit comments