mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:51:57 +00:00
Apparently VS Code's Python support uses port 9000, so as long as we use it most VS Code Python devs can't run the app due to the port conflict with our services. This PR switches the app's blobstore to listen on `:49000` instead of `:9000`. My thinking for now is that we can centralize all "default endpoint" and "what host/port should I listen on?" into the `deploy` package, and for now just change ports to have a `4` in front of them to reduce the change of conflicts. Later, once we have them centralized in the `deploy` package we can easily modify that code to pick an unavailable port. This also binds blobstore to `127.0.0.1` (more secure), previously it was bound to `localhost`. ## Test plan To test this I did the following: 1. [x] Methodically searched our codebase for `9000` and vetted each instance, to ensure I didn't miss anything. 2. [x] Tested with `sg start app` and confirmed `sudo lsof -i -P | grep LISTEN | grep :9000` reported nothing while `sudo lsof -i -P | grep LISTEN | grep :49000` did. 3. [x] Created an app build with `./enterprise/dev/app/build.sh` and tested it: * [x] Confirmed embeddings generation (which get stored in blobstore) still works through the setup wizard 4. [x] Confirmed `sg start enterprise-codeintel` starts and runs Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
69 lines
2.9 KiB
Go
69 lines
2.9 KiB
Go
package shared
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
sglog "github.com/sourcegraph/log"
|
|
|
|
"github.com/sourcegraph/sourcegraph/internal/conf/deploy"
|
|
)
|
|
|
|
func maybeBlobstore(logger sglog.Logger) []string {
|
|
if os.Getenv("DISABLE_BLOBSTORE") != "" {
|
|
logger.Warn("running with blobstore disabled")
|
|
return []string{""}
|
|
}
|
|
|
|
// Point at local blobstore endpoint.
|
|
SetDefaultEnv("PRECISE_CODE_INTEL_UPLOAD_AWS_ENDPOINT", deploy.BlobstoreDefaultEndpoint())
|
|
SetDefaultEnv("PRECISE_CODE_INTEL_UPLOAD_BACKEND", "blobstore")
|
|
|
|
// cmd/server-specific blobstore env vars
|
|
// Note: SetDefaultEnv should be called only once for the same env var, so
|
|
// ensure these do not conflict with the default list set below.
|
|
dataDir := filepath.Join(os.Getenv("DATA_DIR"), "blobstore")
|
|
SetDefaultEnv("JCLOUDS_FILESYSTEM_BASEDIR", dataDir)
|
|
|
|
// Default blobstore env vars copied from the Dockerfile
|
|
// https://github.com/sourcegraph/sourcegraph/blob/main/docker-images/blobstore/Dockerfile
|
|
SetDefaultEnv("LOG_LEVEL", "info")
|
|
SetDefaultEnv("S3PROXY_AUTHORIZATION", "none")
|
|
SetDefaultEnv("S3PROXY_ENDPOINT", "http://0.0.0.0:9000")
|
|
SetDefaultEnv("S3PROXY_IDENTITY", "local-identity")
|
|
SetDefaultEnv("S3PROXY_CREDENTIAL", "local-credential")
|
|
SetDefaultEnv("S3PROXY_VIRTUALHOST", "")
|
|
SetDefaultEnv("S3PROXY_CORS_ALLOW_ALL", "false")
|
|
SetDefaultEnv("S3PROXY_CORS_ALLOW_ORIGINS", "")
|
|
SetDefaultEnv("S3PROXY_CORS_ALLOW_METHODS", "")
|
|
SetDefaultEnv("S3PROXY_CORS_ALLOW_HEADERS", "")
|
|
SetDefaultEnv("S3PROXY_IGNORE_UNKNOWN_HEADERS", "false")
|
|
SetDefaultEnv("S3PROXY_ENCRYPTED_BLOBSTORE", "")
|
|
SetDefaultEnv("S3PROXY_ENCRYPTED_BLOBSTORE_PASSWORD", "")
|
|
SetDefaultEnv("S3PROXY_ENCRYPTED_BLOBSTORE_SALT", "")
|
|
SetDefaultEnv("S3PROXY_V4_MAX_NON_CHUNKED_REQ_SIZE", "33554432")
|
|
SetDefaultEnv("JCLOUDS_PROVIDER", "filesystem")
|
|
SetDefaultEnv("JCLOUDS_ENDPOINT", "")
|
|
SetDefaultEnv("JCLOUDS_REGION", "")
|
|
SetDefaultEnv("JCLOUDS_REGIONS", "us-east-1")
|
|
SetDefaultEnv("JCLOUDS_IDENTITY", "remote-identity")
|
|
SetDefaultEnv("JCLOUDS_CREDENTIAL", "remote-credential")
|
|
SetDefaultEnv("JCLOUDS_KEYSTONE_VERSION", "")
|
|
SetDefaultEnv("JCLOUDS_KEYSTONE_SCOPE", "")
|
|
SetDefaultEnv("JCLOUDS_KEYSTONE_PROJECT_DOMAIN_NAME", "")
|
|
// SetDefaultEnv("JCLOUDS_FILESYSTEM_BASEDIR", dataDir) // overridden above; here for equality with Dockerfile
|
|
// We don't use the secure endpoint, but these values must be set
|
|
SetDefaultEnv("S3PROXY_SECURE_ENDPOINT", "https://0.0.0.0:9443")
|
|
SetDefaultEnv("S3PROXY_KEYSTORE_PATH", "/opt/s3proxy/test-classes/keystore.jks")
|
|
SetDefaultEnv("S3PROXY_KEYSTORE_PASSWORD", "password")
|
|
|
|
// Configure blobstore service
|
|
blobstoreDataDir := os.Getenv("JCLOUDS_FILESYSTEM_BASEDIR")
|
|
if err := os.MkdirAll(blobstoreDataDir, os.ModePerm); err != nil {
|
|
logger.Error("failed to create blobstore data dir (JCLOUDS_FILESYSTEM_BASEDIR)", sglog.Error(err))
|
|
}
|
|
|
|
procline := `blobstore: /opt/s3proxy/run-docker-container.sh >> /var/opt/sourcegraph/blobstore.log 2>&1`
|
|
return []string{procline}
|
|
}
|