mirror of
https://github.com/go-gitea/gitea
synced 2025-09-18 14:48:13 +00:00
Fix context usages (#35348)
This commit is contained in:
@@ -100,7 +100,7 @@ func runRepoSyncReleases(ctx context.Context, _ *cli.Command) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := git.InitSimple(ctx); err != nil {
|
||||
if err := git.InitSimple(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -128,7 +128,7 @@ func runRecreateTable(ctx context.Context, cmd *cli.Command) error {
|
||||
}
|
||||
recreateTables := migrate_base.RecreateTables(beans...)
|
||||
|
||||
return db.InitEngineWithMigration(ctx, func(ctx context.Context, x *xorm.Engine) error {
|
||||
return db.InitEngineWithMigration(context.Background(), func(ctx context.Context, x *xorm.Engine) error {
|
||||
if err := migrations.EnsureUpToDate(ctx, x); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ func runDumpRepository(ctx context.Context, cmd *cli.Command) error {
|
||||
}
|
||||
|
||||
// migrations.GiteaLocalUploader depends on git module
|
||||
if err := git.InitSimple(context.Background()); err != nil {
|
||||
if err := git.InitSimple(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ func runDumpRepository(ctx context.Context, cmd *cli.Command) error {
|
||||
}
|
||||
|
||||
if err := migrations.DumpRepository(
|
||||
context.Background(),
|
||||
ctx,
|
||||
repoDir,
|
||||
cmd.String("owner_name"),
|
||||
opts,
|
||||
|
@@ -65,7 +65,7 @@ func setup(ctx context.Context, debug bool) {
|
||||
_ = fail(ctx, "Unable to access repository path", "Unable to access repository path %q, err: %v", setting.RepoRootPath, err)
|
||||
return
|
||||
}
|
||||
if err := git.InitSimple(context.Background()); err != nil {
|
||||
if err := git.InitSimple(); err != nil {
|
||||
_ = fail(ctx, "Failed to init git", "Failed to init git, err: %v", err)
|
||||
}
|
||||
}
|
||||
|
@@ -236,15 +236,16 @@ func serveInstalled(c *cli.Command) error {
|
||||
}
|
||||
|
||||
func servePprof() {
|
||||
// FIXME: it shouldn't use the global DefaultServeMux, and it should use a proper context
|
||||
http.DefaultServeMux.Handle("/debug/fgprof", fgprof.Handler())
|
||||
_, _, finished := process.GetManager().AddTypedContext(context.Background(), "Web: PProf Server", process.SystemProcessType, true)
|
||||
// The pprof server is for debug purpose only, it shouldn't be exposed on public network. At the moment it's not worth to introduce a configurable option for it.
|
||||
_, _, finished := process.GetManager().AddTypedContext(context.TODO(), "Web: PProf Server", process.SystemProcessType, true)
|
||||
// The pprof server is for debug purpose only, it shouldn't be exposed on public network. At the moment, it's not worth introducing a configurable option for it.
|
||||
log.Info("Starting pprof server on localhost:6060")
|
||||
log.Info("Stopped pprof server: %v", http.ListenAndServe("localhost:6060", nil))
|
||||
finished()
|
||||
}
|
||||
|
||||
func runWeb(_ context.Context, cmd *cli.Command) error {
|
||||
func runWeb(ctx context.Context, cmd *cli.Command) error {
|
||||
defer func() {
|
||||
if panicked := recover(); panicked != nil {
|
||||
log.Fatal("PANIC: %v\n%s", panicked, log.Stack(2))
|
||||
@@ -255,7 +256,7 @@ func runWeb(_ context.Context, cmd *cli.Command) error {
|
||||
return fmt.Errorf("unknown command: %s", subCmdName)
|
||||
}
|
||||
|
||||
managerCtx, cancel := context.WithCancel(context.Background())
|
||||
managerCtx, cancel := context.WithCancel(ctx)
|
||||
graceful.InitManager(managerCtx)
|
||||
defer cancel()
|
||||
|
||||
|
Reference in New Issue
Block a user