Merge branch 'nightly' into migration
This commit is contained in:
+38
-11
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/shuffle/shuffle-shared"
|
||||
singul "github.com/shuffle/singul/pkg"
|
||||
|
||||
"net/http/pprof"
|
||||
//"net/http/pprof"
|
||||
|
||||
"archive/zip"
|
||||
"bufio"
|
||||
@@ -78,6 +78,7 @@ type retStruct struct {
|
||||
Reason string `json:"reason"`
|
||||
Subscriptions []shuffle.PaymentSubscription `json:"subscriptions"`
|
||||
Licensed bool `json:"licensed"`
|
||||
CloudSyncUrl string `json:"cloud_sync_url,omitempty"`
|
||||
}
|
||||
|
||||
type Contact struct {
|
||||
@@ -3859,6 +3860,7 @@ func remoteOrgJobController(org shuffle.Org, body []byte) error {
|
||||
SyncFeatures shuffle.SyncFeatures `json:"sync_features"`
|
||||
Subscriptions []shuffle.PaymentSubscription `json:"subscriptions"`
|
||||
Licensed bool `json:"licensed"`
|
||||
CloudSyncUrl string `json:"cloud_sync_url,omitempty"`
|
||||
}
|
||||
|
||||
responseData := retStruct{}
|
||||
@@ -4036,6 +4038,19 @@ func remoteOrgJobHandler(org shuffle.Org, interval int) error {
|
||||
backupJobData = []byte{}
|
||||
}
|
||||
|
||||
cloudSyncRegionUrlCacheKey := fmt.Sprintf("org_cloudsync_region_url_%s", org.Id)
|
||||
cloudSyncRegionUrlCached, err := shuffle.GetCache(ctx, cloudSyncRegionUrlCacheKey)
|
||||
if err == nil {
|
||||
if cachedBytes, ok := cloudSyncRegionUrlCached.([]byte); ok && len(cachedBytes) > 0 {
|
||||
syncUrl = string(cachedBytes)
|
||||
log.Printf("[DEBUG] Using cached cloud sync region url for org %s: %s", org.Id, syncUrl)
|
||||
}
|
||||
}
|
||||
|
||||
if len(syncUrl) == 0 || !strings.HasPrefix(syncUrl, "http") {
|
||||
syncUrl = "https://shuffler.io"
|
||||
}
|
||||
|
||||
syncUrl := fmt.Sprintf("%s/api/v1/cloud/sync", syncUrl)
|
||||
client := shuffle.GetExternalClient(syncUrl)
|
||||
req, err := http.NewRequest(
|
||||
@@ -4880,6 +4895,12 @@ func handleCloudSetup(resp http.ResponseWriter, request *http.Request) {
|
||||
//log.Printf("Apidata: %s", tmpData.Apikey)
|
||||
|
||||
// FIXME: Path
|
||||
|
||||
// just in case setup/stop URL is overwritten by region url
|
||||
if syncUrl != "https://shuffler.io" || syncUrl != "http://localhost:5002" {
|
||||
syncUrl = "https://shuffler.io"
|
||||
}
|
||||
|
||||
apiPath := "/api/v1/cloud/sync/setup"
|
||||
if tmpData.Disable {
|
||||
if !org.CloudSync {
|
||||
@@ -5028,6 +5049,11 @@ func handleCloudSetup(resp http.ResponseWriter, request *http.Request) {
|
||||
shuffle.SetCache(ctx, licenseCacheKey, licensedBytes, 1800)
|
||||
}
|
||||
|
||||
if len(responseData.CloudSyncUrl) > 0 {
|
||||
cloudSyncRegionUrlCacheKey := fmt.Sprintf("org_cloudsync_region_url_%s", org.Id)
|
||||
shuffle.SetCache(ctx, cloudSyncRegionUrlCacheKey, []byte(responseData.CloudSyncUrl), 1800)
|
||||
}
|
||||
|
||||
org.SyncConfig = shuffle.SyncConfig{
|
||||
Apikey: responseData.SessionKey,
|
||||
Interval: responseData.IntervalSeconds,
|
||||
@@ -5656,16 +5682,17 @@ func initHandlers() {
|
||||
r.HandleFunc("/api/v1/dashboards/{key}/widgets", shuffle.HandleNewWidget).Methods("POST", "OPTIONS")
|
||||
r.HandleFunc("/api/v1/dashboards/{key}/widgets/{widget_id}", shuffle.HandleGetWidget).Methods("GET", "OPTIONS")
|
||||
|
||||
if strings.ToLower(os.Getenv("SHUFFLE_DEBUG_MEMORY")) == "true" || strings.ToLower(os.Getenv("DEBUG_MEMORY")) == "true" {
|
||||
log.Printf("[DEBUG] Memory debugging is enabled on /debug/pprof")
|
||||
r.HandleFunc("/debug/pprof/", pprof.Index)
|
||||
r.HandleFunc("/debug/pprof/heap", pprof.Handler("heap").ServeHTTP)
|
||||
r.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
||||
r.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||
r.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||
} else {
|
||||
log.Printf("[DEBUG] Memory debugging is disabled. To enable, set SHUFFLE_DEBUG_MEMORY or DEBUG_MEMORY to true")
|
||||
}
|
||||
// Need to add auth in pprof
|
||||
// if strings.ToLower(os.Getenv("SHUFFLE_DEBUG_MEMORY")) == "true" || strings.ToLower(os.Getenv("DEBUG_MEMORY")) == "true" {
|
||||
// log.Printf("[DEBUG] Memory debugging is enabled on /debug/pprof")
|
||||
// r.HandleFunc("/debug/pprof/", pprof.Index)
|
||||
// r.HandleFunc("/debug/pprof/heap", pprof.Handler("heap").ServeHTTP)
|
||||
// r.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
||||
// r.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||
// r.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||
// } else {
|
||||
// log.Printf("[DEBUG] Memory debugging is disabled. To enable, set SHUFFLE_DEBUG_MEMORY or DEBUG_MEMORY to true")
|
||||
// }
|
||||
|
||||
r.Use(shuffle.RequestMiddleware)
|
||||
http.Handle("/", r)
|
||||
|
||||
Reference in New Issue
Block a user