66 "../serverError"
77 "../serverHandler"
88 "../serverLog"
9+ "../setting"
910 "../tpl"
1011 "../util"
1112 "os"
@@ -31,15 +32,15 @@ func (app *App) ReOpenLog() []error {
3132 return app .logFileMan .Reopen ()
3233}
3334
34- func NewApp (params []* param.Param ) (* App , []error ) {
35- errs := writePidFile ()
36- if len (errs ) > 0 {
37- return nil , errs
35+ func NewApp (params []* param.Param , setting * setting.Setting ) (* App , []error ) {
36+ if len (setting .PidFile ) > 0 {
37+ errs := writePidFile (setting .PidFile )
38+ if len (errs ) > 0 {
39+ return nil , errs
40+ }
3841 }
3942
40- verbose := ! util .GetBoolEnv ("GHFS_QUIET" )
41-
42- if serverHandler .TryEnableWSL1Fix () && verbose {
43+ if serverHandler .TryEnableWSL1Fix () && ! setting .Quiet {
4344 ttyFile , teardownTtyFile := util .GetTTYFile ()
4445 ttyFile .WriteString ("WSL 1 compatible mode enabled\n " )
4546 teardownTtyFile ()
@@ -114,7 +115,7 @@ func NewApp(params []*param.Param) (*App, []error) {
114115 }
115116 }
116117
117- if verbose {
118+ if ! setting . Quiet {
118119 go printAccessibleURLs (vhSvc )
119120 }
120121
@@ -124,12 +125,7 @@ func NewApp(params []*param.Param) (*App, []error) {
124125 }, nil
125126}
126127
127- func writePidFile () (errs []error ) {
128- pidFilename := os .Getenv ("GHFS_PID_FILE" )
129- if len (pidFilename ) == 0 {
130- return nil
131- }
132-
128+ func writePidFile (pidFilename string ) (errs []error ) {
133129 pidContent := strconv .Itoa (os .Getpid ())
134130 pidFile , err := os .OpenFile (pidFilename , os .O_CREATE | os .O_TRUNC | os .O_WRONLY , 0644 )
135131 if err != nil {
0 commit comments