loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'Remove some Windows-specific files' (#5353) from 0ko/forgejo:no-windows into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5353
Reviewed-by: Otto <otto@codeberg.org>

Otto 2c4a3d66 386e3d17

-291
-1
go.mod
··· 84 84 github.com/opencontainers/image-spec v1.1.0 85 85 github.com/pquerna/otp v1.4.0 86 86 github.com/prometheus/client_golang v1.18.0 87 - github.com/quasoft/websspi v1.1.2 88 87 github.com/redis/go-redis/v9 v9.6.1 89 88 github.com/robfig/cron/v3 v3.0.1 90 89 github.com/santhosh-tekuri/jsonschema/v6 v6.0.1
-5
go.sum
··· 379 379 github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= 380 380 github.com/gorilla/pat v0.0.0-20180118222023-199c85a7f6d1 h1:LqbZZ9sNMWVjeXS4NN5oVvhMjDyLhmA1LG86oSo+IqY= 381 381 github.com/gorilla/pat v0.0.0-20180118222023-199c85a7f6d1/go.mod h1:YeAe0gNeiNT5hoiZRI4yiOky6jVdNvfO2N6Kav/HmxY= 382 - github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= 383 382 github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= 384 383 github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= 385 - github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= 386 384 github.com/gorilla/sessions v1.2.2 h1:lqzMYz6bOfvn2WriPUjNByzeXIlVzURcPmgMczkmTjY= 387 385 github.com/gorilla/sessions v1.2.2/go.mod h1:ePLdVu+jbEgHH+KWw8I1z2wqd0BAdAQh/8LRvBeoNcQ= 388 386 github.com/h2non/gock v1.2.0 h1:K6ol8rfrRkUOefooBC8elXoaNGYkpp7y2qcxGG6BzUE= ··· 581 579 github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= 582 580 github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= 583 581 github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= 584 - github.com/quasoft/websspi v1.1.2 h1:/mA4w0LxWlE3novvsoEL6BBA1WnjJATbjkh1kFrTidw= 585 - github.com/quasoft/websspi v1.1.2/go.mod h1:HmVdl939dQ0WIXZhyik+ARdI03M6bQzaSEKcgpFmewk= 586 582 github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4= 587 583 github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA= 588 584 github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= ··· 779 775 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 780 776 golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 781 777 golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 782 - golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 783 778 golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 784 779 golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 785 780 golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-190
modules/graceful/manager_windows.go
··· 1 - // Copyright 2019 The Gitea Authors. All rights reserved. 2 - // SPDX-License-Identifier: MIT 3 - // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler 4 - 5 - //go:build windows 6 - 7 - package graceful 8 - 9 - import ( 10 - "os" 11 - "runtime/pprof" 12 - "strconv" 13 - "time" 14 - 15 - "code.gitea.io/gitea/modules/log" 16 - "code.gitea.io/gitea/modules/setting" 17 - 18 - "golang.org/x/sys/windows/svc" 19 - "golang.org/x/sys/windows/svc/debug" 20 - ) 21 - 22 - // WindowsServiceName is the name of the Windows service 23 - var WindowsServiceName = "gitea" 24 - 25 - const ( 26 - hammerCode = 128 27 - hammerCmd = svc.Cmd(hammerCode) 28 - acceptHammerCode = svc.Accepted(hammerCode) 29 - ) 30 - 31 - func (g *Manager) start() { 32 - // Now label this and all goroutines created by this goroutine with the gracefulLifecycle manager 33 - pprof.SetGoroutineLabels(g.managerCtx) 34 - defer pprof.SetGoroutineLabels(g.ctx) 35 - 36 - if skip, _ := strconv.ParseBool(os.Getenv("SKIP_MINWINSVC")); skip { 37 - log.Trace("Skipping SVC check as SKIP_MINWINSVC is set") 38 - return 39 - } 40 - 41 - // Make SVC process 42 - run := svc.Run 43 - 44 - //lint:ignore SA1019 We use IsAnInteractiveSession because IsWindowsService has a different permissions profile 45 - isAnInteractiveSession, err := svc.IsAnInteractiveSession() //nolint:staticcheck 46 - if err != nil { 47 - log.Error("Unable to ascertain if running as an Windows Service: %v", err) 48 - return 49 - } 50 - if isAnInteractiveSession { 51 - log.Trace("Not running a service ... using the debug SVC manager") 52 - run = debug.Run 53 - } 54 - go func() { 55 - _ = run(WindowsServiceName, g) 56 - }() 57 - } 58 - 59 - // Execute makes Manager implement svc.Handler 60 - func (g *Manager) Execute(args []string, changes <-chan svc.ChangeRequest, status chan<- svc.Status) (svcSpecificEC bool, exitCode uint32) { 61 - if setting.StartupTimeout > 0 { 62 - status <- svc.Status{State: svc.StartPending, WaitHint: uint32(setting.StartupTimeout / time.Millisecond)} 63 - } else { 64 - status <- svc.Status{State: svc.StartPending} 65 - } 66 - 67 - log.Trace("Awaiting server start-up") 68 - // Now need to wait for everything to start... 69 - if !g.awaitServer(setting.StartupTimeout) { 70 - log.Trace("... start-up failed ... Stopped") 71 - return false, 1 72 - } 73 - 74 - log.Trace("Sending Running state to SVC") 75 - 76 - // We need to implement some way of svc.AcceptParamChange/svc.ParamChange 77 - status <- svc.Status{ 78 - State: svc.Running, 79 - Accepts: svc.AcceptStop | svc.AcceptShutdown | acceptHammerCode, 80 - } 81 - 82 - log.Trace("Started") 83 - 84 - waitTime := 30 * time.Second 85 - 86 - loop: 87 - for { 88 - select { 89 - case <-g.ctx.Done(): 90 - log.Trace("Shutting down") 91 - g.DoGracefulShutdown() 92 - waitTime += setting.GracefulHammerTime 93 - break loop 94 - case <-g.shutdownRequested: 95 - log.Trace("Shutting down") 96 - waitTime += setting.GracefulHammerTime 97 - break loop 98 - case change := <-changes: 99 - switch change.Cmd { 100 - case svc.Interrogate: 101 - log.Trace("SVC sent interrogate") 102 - status <- change.CurrentStatus 103 - case svc.Stop, svc.Shutdown: 104 - log.Trace("SVC requested shutdown - shutting down") 105 - g.DoGracefulShutdown() 106 - waitTime += setting.GracefulHammerTime 107 - break loop 108 - case hammerCode: 109 - log.Trace("SVC requested hammer - shutting down and hammering immediately") 110 - g.DoGracefulShutdown() 111 - g.DoImmediateHammer() 112 - break loop 113 - default: 114 - log.Debug("Unexpected control request: %v", change.Cmd) 115 - } 116 - } 117 - } 118 - 119 - log.Trace("Sending StopPending state to SVC") 120 - status <- svc.Status{ 121 - State: svc.StopPending, 122 - WaitHint: uint32(waitTime / time.Millisecond), 123 - } 124 - 125 - hammerLoop: 126 - for { 127 - select { 128 - case change := <-changes: 129 - switch change.Cmd { 130 - case svc.Interrogate: 131 - log.Trace("SVC sent interrogate") 132 - status <- change.CurrentStatus 133 - case svc.Stop, svc.Shutdown, hammerCmd: 134 - log.Trace("SVC requested hammer - hammering immediately") 135 - g.DoImmediateHammer() 136 - break hammerLoop 137 - default: 138 - log.Debug("Unexpected control request: %v", change.Cmd) 139 - } 140 - case <-g.hammerCtx.Done(): 141 - break hammerLoop 142 - } 143 - } 144 - 145 - log.Trace("Stopped") 146 - return false, 0 147 - } 148 - 149 - func (g *Manager) awaitServer(limit time.Duration) bool { 150 - c := make(chan struct{}) 151 - go func() { 152 - g.createServerCond.L.Lock() 153 - for { 154 - if g.createdServer >= numberOfServersToCreate { 155 - g.createServerCond.L.Unlock() 156 - close(c) 157 - return 158 - } 159 - select { 160 - case <-g.IsShutdown(): 161 - g.createServerCond.L.Unlock() 162 - return 163 - default: 164 - } 165 - g.createServerCond.Wait() 166 - } 167 - }() 168 - 169 - var tc <-chan time.Time 170 - if limit > 0 { 171 - tc = time.After(limit) 172 - } 173 - select { 174 - case <-c: 175 - return true // completed normally 176 - case <-tc: 177 - return false // timed out 178 - case <-g.IsShutdown(): 179 - g.createServerCond.Signal() 180 - return false 181 - } 182 - } 183 - 184 - func (g *Manager) notify(msg systemdNotifyMsg) { 185 - // Windows doesn't use systemd to notify 186 - } 187 - 188 - func KillParent() { 189 - // Windows doesn't need to "kill parent" because there is no graceful restart 190 - }
-19
modules/graceful/net_windows.go
··· 1 - // Copyright 2019 The Gitea Authors. All rights reserved. 2 - // SPDX-License-Identifier: MIT 3 - 4 - // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler 5 - 6 - //go:build windows 7 - 8 - package graceful 9 - 10 - import "net" 11 - 12 - // DefaultGetListener obtains a listener for the local network address. 13 - // On windows this is basically just a shim around net.Listen. 14 - func DefaultGetListener(network, address string) (net.Listener, error) { 15 - // Add a deferral to say that we've tried to grab a listener 16 - defer GetManager().InformCleanup() 17 - 18 - return net.Listen(network, address) 19 - }
-15
modules/process/manager_windows.go
··· 1 - // Copyright 2022 The Gitea Authors. All rights reserved. 2 - // SPDX-License-Identifier: MIT 3 - 4 - //go:build windows 5 - 6 - package process 7 - 8 - import ( 9 - "os/exec" 10 - ) 11 - 12 - // SetSysProcAttribute sets the common SysProcAttrs for commands 13 - func SetSysProcAttribute(cmd *exec.Cmd) { 14 - // Do nothing 15 - }
-15
modules/util/file_windows.go
··· 1 - // Copyright 2022 The Gitea Authors. All rights reserved. 2 - // SPDX-License-Identifier: MIT 3 - 4 - //go:build windows 5 - 6 - package util 7 - 8 - import ( 9 - "os" 10 - ) 11 - 12 - func ApplyUmask(f string, newMode os.FileMode) error { 13 - // do nothing for Windows, because Windows doesn't use umask 14 - return nil 15 - }
-27
routers/private/manager_windows.go
··· 1 - // Copyright 2020 The Gitea Authors. All rights reserved. 2 - // SPDX-License-Identifier: MIT 3 - 4 - //go:build windows 5 - 6 - package private 7 - 8 - import ( 9 - "net/http" 10 - 11 - "code.gitea.io/gitea/modules/graceful" 12 - "code.gitea.io/gitea/modules/private" 13 - "code.gitea.io/gitea/services/context" 14 - ) 15 - 16 - // Restart is not implemented for Windows based servers as they can't fork 17 - func Restart(ctx *context.PrivateContext) { 18 - ctx.JSON(http.StatusNotImplemented, private.Response{ 19 - UserMsg: "windows servers cannot be gracefully restarted - shutdown and restart manually", 20 - }) 21 - } 22 - 23 - // Shutdown causes the server to perform a graceful shutdown 24 - func Shutdown(ctx *context.PrivateContext) { 25 - graceful.GetManager().DoGracefulShutdown() 26 - ctx.PlainText(http.StatusOK, "success") 27 - }
-19
services/auth/sspiauth_windows.go
··· 1 - // Copyright 2023 The Gitea Authors. All rights reserved. 2 - // SPDX-License-Identifier: MIT 3 - 4 - //go:build windows 5 - 6 - package auth 7 - 8 - import ( 9 - "github.com/quasoft/websspi" 10 - ) 11 - 12 - type SSPIUserInfo = websspi.UserInfo 13 - 14 - func sspiAuthInit() error { 15 - var err error 16 - config := websspi.NewConfig() 17 - sspiAuth, err = websspi.New(config) 18 - return err 19 - }