@@ -148,7 +148,14 @@ func getInstalledPhpVersion(ctx *gcp.Context) (string, error) {
148
148
return resolvedVersion , nil
149
149
}
150
150
151
- func supportsDecorateWorkersOutput (ctx * gcp.Context ) (bool , error ) {
151
+ // isVersion73OrGreater checks if the installed PHP version is 7.3.0 or newer.
152
+ // This is used to enable features like 'decorate_workers_output = no' and 'log_limit'.
153
+ // (1) For php >= 7.3.0, the directive decorate_workers_output prevents php from prepending a warning
154
+ // message to all logged entries. Prior to 7.3.0, decorate_workers_output was not available, and
155
+ // these warning messages were prepended to all logged entries. Here we choose to set
156
+ // decorate_workers_output = no if the runtime version is >= 7.3.0.
157
+ // (2) Set log_limit to 256kb.
158
+ func isVersion73OrGreater (ctx * gcp.Context ) (bool , error ) {
152
159
v , err := getInstalledPhpVersion (ctx )
153
160
if err != nil {
154
161
return false , err
@@ -172,22 +179,18 @@ func supportsDecorateWorkersOutput(ctx *gcp.Context) (bool, error) {
172
179
}
173
180
174
181
func writeFpmConfig (ctx * gcp.Context , path string , overrides webconfig.OverrideProperties ) (* os.File , error ) {
175
- // For php >= 7.3.0, the directive decorate_workers_output prevents php from prepending a warning
176
- // message to all logged entries. Prior to 7.3.0, decorate_workers_output was not available, and
177
- // these warning messages are prepended to all logged entries. Here we choose to set
178
- // decorate_workers_output if the runtime version is >= 7.3.0.
179
- addNoDecorateWorkers , err := supportsDecorateWorkersOutput (ctx )
182
+ isVersion73OrGreater , err := isVersion73OrGreater (ctx )
180
183
if err != nil {
181
184
return nil , err
182
185
}
183
- conf , err := fpmConfig (path , addNoDecorateWorkers , overrides )
186
+ conf , err := fpmConfig (path , isVersion73OrGreater , overrides )
184
187
if err != nil {
185
188
return nil , err
186
189
}
187
190
return nginx .WriteFpmConfigToPath (path , conf )
188
191
}
189
192
190
- func fpmConfig (layer string , addNoDecorateWorkers bool , overrides webconfig.OverrideProperties ) (nginx.FPMConfig , error ) {
193
+ func fpmConfig (layer string , isVersion73OrGreater bool , overrides webconfig.OverrideProperties ) (nginx.FPMConfig , error ) {
191
194
user , err := user .Current ()
192
195
if err != nil {
193
196
return nginx.FPMConfig {}, fmt .Errorf ("getting current user: %w" , err )
@@ -199,7 +202,8 @@ func fpmConfig(layer string, addNoDecorateWorkers bool, overrides webconfig.Over
199
202
ListenAddress : filepath .Join (layer , appSocket ),
200
203
DynamicWorkers : defaultDynamicWorkers ,
201
204
Username : user .Username ,
202
- AddNoDecorateWorkers : addNoDecorateWorkers ,
205
+ AddNoDecorateWorkers : isVersion73OrGreater ,
206
+ UseLogLimit : isVersion73OrGreater ,
203
207
}
204
208
205
209
if env .IsFlex () {
0 commit comments