mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 19:21:50 +00:00
* internal: add service and singleprogram packages
* sg.config.yaml: add single-binary build targets
* internal/env: add a function for clearing environ cache
* internal/{workerutil,metrics}: add a hack to allow running 2 executors in the same process
* internal/conf: add single-program deploy type
* internal/singleprogram: clarify security
* cmd/sourcegraph-oss: add initial single-binary main (will not build yet)
* enterprise/cmd/sourcegraph: initial enterprise single-binary
* Add multi-platform builds for single-program
* single-binary: correctly build JS artifacts into binary
* license_finder licenses add github.com/xi2/xz "Public domain"
* internal/service/svcmain: correctly initialize logger for DeprecatedSingleServiceMain
* worker: refactor to new service pattern
* cmd/github-proxy: refactor to use new service pattern
* symbols: refactor to use new service pattern
* gitserver: refactor to user new service pattern
* searcher: refactor to use new service pattern
* gitserver: refactor to use new service pattern
* repo-updater: refactor to use new service pattern
* frontend: refactor to use new service pattern
* executor: refactor to use new service pattern
* internal/symbols: use new LoadConfig pattern
* precise-code-intel-worker: refactor to use new service pattern
* internal/symbols: load config for tests
* cmd/repo-updater: remove LoadConfig approach
* cmd/symbols: workaround env var conflict with searcher
* executor: internal: add workaround to allow running 2 instances in same process
* executors: add EXECUTOR_QUEUE_DISABLE_ACCESS_TOKEN for single-binary and dev deployments only
* single-binary: use EXECUTOR_QUEUE_DISABLE_ACCESS_TOKEN
* extsvc/github: fix default value for single-program deploy type
* single-binary: stop relying on a local ctags image
* single-binary: use unix sockets for postgres
* release App snapshots in CI when pushed to app/release-snapshot branch
* internal/service/svcmain: update TODO comment
* executor: correct DEPLOY_TYPE check
* dev/check: allow single-binary to import dbconn
* executor: remove accidental reliance on dbconn package
* executor: improve error logging when running commands (#46546)
* executor: improve error logging when running commands
* executor: do not attempt std config validation running e.g. install cmd
* executor: do not pull in the conf package / frontend reliance
* ci: executors: correct site config for passwordless auth
* server: fix bug where github-proxy would try to be a conf server
* CI: executors: fix integration test passwordless auth
* executors: allow passwordless auth in sourcegraph/server for testing
* repo-updater: fix enterprise init (caused regression in repository syncing)
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Co-authored-by: Peter Guy <peter.guy@sourcegraph.com>
Co-authored-by: Quinn Slack <quinn@slack.org>
69 lines
2.9 KiB
Go
69 lines
2.9 KiB
Go
package shared
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"golang.org/x/sync/semaphore"
|
|
|
|
"github.com/sourcegraph/go-ctags"
|
|
"github.com/sourcegraph/log"
|
|
|
|
"github.com/sourcegraph/sourcegraph/cmd/symbols/fetcher"
|
|
"github.com/sourcegraph/sourcegraph/cmd/symbols/gitserver"
|
|
"github.com/sourcegraph/sourcegraph/cmd/symbols/internal/api"
|
|
sqlite "github.com/sourcegraph/sourcegraph/cmd/symbols/internal/database"
|
|
"github.com/sourcegraph/sourcegraph/cmd/symbols/internal/database/janitor"
|
|
"github.com/sourcegraph/sourcegraph/cmd/symbols/internal/database/writer"
|
|
"github.com/sourcegraph/sourcegraph/cmd/symbols/parser"
|
|
"github.com/sourcegraph/sourcegraph/cmd/symbols/types"
|
|
"github.com/sourcegraph/sourcegraph/internal/database"
|
|
"github.com/sourcegraph/sourcegraph/internal/diskcache"
|
|
"github.com/sourcegraph/sourcegraph/internal/goroutine"
|
|
"github.com/sourcegraph/sourcegraph/internal/observation"
|
|
)
|
|
|
|
func LoadConfig() {
|
|
RepositoryFetcherConfig = types.LoadRepositoryFetcherConfig(baseConfig)
|
|
CtagsConfig = types.LoadCtagsConfig(baseConfig)
|
|
config = types.LoadSqliteConfig(baseConfig, CtagsConfig, RepositoryFetcherConfig)
|
|
}
|
|
|
|
var config types.SqliteConfig
|
|
|
|
func SetupSqlite(observationCtx *observation.Context, db database.DB, gitserverClient gitserver.GitserverClient, repositoryFetcher fetcher.RepositoryFetcher) (types.SearchFunc, func(http.ResponseWriter, *http.Request), []goroutine.BackgroundRoutine, string, error) {
|
|
logger := observationCtx.Logger.Scoped("sqlite.setup", "SQLite setup")
|
|
|
|
if err := baseConfig.Validate(); err != nil {
|
|
logger.Fatal("failed to load configuration", log.Error(err))
|
|
}
|
|
|
|
// Ensure we register our database driver before calling
|
|
// anything that tries to open a SQLite database.
|
|
sqlite.Init()
|
|
|
|
parserFactory := func() (ctags.Parser, error) {
|
|
return parser.SpawnCtags(logger, config.Ctags)
|
|
}
|
|
parserPool, err := parser.NewParserPool(parserFactory, config.NumCtagsProcesses)
|
|
if err != nil {
|
|
logger.Fatal("failed to create parser pool", log.Error(err))
|
|
}
|
|
|
|
cache := diskcache.NewStore(config.CacheDir, "symbols",
|
|
diskcache.WithBackgroundTimeout(config.ProcessingTimeout),
|
|
diskcache.WithobservationCtx(observationCtx),
|
|
)
|
|
|
|
parser := parser.NewParser(observationCtx, parserPool, repositoryFetcher, config.RequestBufferSize, config.NumCtagsProcesses)
|
|
databaseWriter := writer.NewDatabaseWriter(observationCtx, config.CacheDir, gitserverClient, parser, semaphore.NewWeighted(int64(config.MaxConcurrentlyIndexing)))
|
|
cachedDatabaseWriter := writer.NewCachedDatabaseWriter(databaseWriter, cache)
|
|
searchFunc := api.MakeSqliteSearchFunc(observationCtx, cachedDatabaseWriter, db)
|
|
|
|
evictionInterval := time.Second * 10
|
|
cacheSizeBytes := int64(config.CacheSizeMB) * 1000 * 1000
|
|
cacheEvicter := janitor.NewCacheEvicter(evictionInterval, cache, cacheSizeBytes, janitor.NewMetrics(observationCtx))
|
|
|
|
return searchFunc, nil, []goroutine.BackgroundRoutine{cacheEvicter}, config.Ctags.Command, nil
|
|
}
|