fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

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

1// This file contains commands which run in a non daemon mode for testing/debugging. 2 3package main 4 5import ( 6 "context" 7 "flag" 8 "fmt" 9 "log" 10 "strconv" 11 12 "github.com/peterbourgon/ff/v3/ffcli" 13) 14 15func debugIndex() *ffcli.Command { 16 fs := flag.NewFlagSet("debug index", flag.ExitOnError) 17 conf := rootConfig{} 18 conf.registerRootFlags(fs) 19 20 return &ffcli.Command{ 21 Name: "index", 22 ShortUsage: "index [flags] <repository ID>", 23 ShortHelp: "index a repository", 24 FlagSet: fs, 25 Exec: func(ctx context.Context, args []string) error { 26 if len(args) == 0 { 27 return fmt.Errorf("missing repository ID") 28 } 29 s, err := newServer(conf) 30 if err != nil { 31 return err 32 } 33 id, err := strconv.Atoi(args[0]) 34 if err != nil { 35 return err 36 } 37 msg, err := s.forceIndex(uint32(id)) 38 log.Println(msg) 39 if err != nil { 40 return err 41 } 42 return nil 43 }, 44 } 45} 46 47func debugTrigrams() *ffcli.Command { 48 return &ffcli.Command{ 49 Name: "trigrams", 50 ShortUsage: "trigrams <path/to/shard>", 51 ShortHelp: "list all the trigrams in a shard", 52 Exec: func(ctx context.Context, args []string) error { 53 if len(args) == 0 { 54 return fmt.Errorf("missing path to shard") 55 } 56 return printShardStats(args[0]) 57 }, 58 } 59} 60 61func debugMeta() *ffcli.Command { 62 return &ffcli.Command{ 63 Name: "meta", 64 ShortUsage: "meta <path/to/shard>", 65 ShortHelp: "output index and repo metadata", 66 Exec: func(ctx context.Context, args []string) error { 67 if len(args) == 0 { 68 return fmt.Errorf("missing path to shard") 69 } 70 return printMetaData(args[0]) 71 }, 72 } 73} 74 75func debugCmd() *ffcli.Command { 76 fs := flag.NewFlagSet("debug", flag.ExitOnError) 77 78 return &ffcli.Command{ 79 Name: "debug", 80 ShortUsage: "debug <subcommand>", 81 ShortHelp: "a set of commands for debugging and testing", 82 LongHelp: ` 83 Zoekt-sourcegraph-indexserver exposes debug information on the /debug landing page. 84 You can use the following wget commands to access this information from the command line. 85 86 wget -q -O - http://localhost:6072/debug/indexed 87 list the repositories that are INDEXED by this instance. 88 89 wget -q -O - http://localhost:6072/debug/list[?indexed=TRUE/false] 90 list the repositories that are OWNED by this instance. If indexed=true (default), the list may contain repositories 91 that this instance holds temporarily, for example during rebalancing. 92 93 wget -q -O - http://localhost:6072/debug/merge 94 start a full merge operation in the index directory. You can check the status with 95 "wget -q -O - http://localhost:6072/metrics -sS | grep index_shard_merging_running". It is only possible 96 to trigger one merge operation at a time. 97 98 wget -q -O - http://localhost:6072/debug/queue 99 list the repositories in the indexing queue, sorted by descending priority. 100 101 COLUMN HEADERS 102 Position zero-indexed position of this repository in the indexing queue (sorted by priority). 103 Name name for this repository 104 ID ID for this repository 105 IsOnQueue "true" if this repository has an outstanding indexing job that's enqueued for future work. "false" otherwise. 106 Age amount of time that this repository has spent in the indexing queue since its outstanding indexing job 107 was first added (ignoring any job metadata updates that may have occurred while it was still enqueued). 108 A "-" is printed instead if this repository doesn't have an outstanding job. 109 Branches comma-separated list of branches in $BRANCH_NAME@$COMMIT_HASH format. 110 If the repository has a job on the indexing queue, this list represents the desired set of 111 branches + associated commits that will be process during the next indexing job. 112 However, if the repository doesn't have a job on the queue, this list represents the set of 113 branches + associated commits that was indexed during its most recent indexing job.`, 114 FlagSet: fs, 115 Subcommands: []*ffcli.Command{ 116 debugIndex(), 117 debugMeta(), 118 debugTrigrams(), 119 }, 120 } 121}