Skip to content

Commit

Permalink
#190 headless broken.
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinedwv committed Apr 18, 2023
1 parent ab2fc0f commit 1e08c39
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 22 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.0.9
v3.0.9_dev2
2 changes: 1 addition & 1 deletion cmd/glcon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import (
var VERSION string

func main() {
log.Info("version: ", VERSION)
log.Print("version: ", VERSION)
cli.Execute()
}
27 changes: 7 additions & 20 deletions internal/summoner/acquire/headlessNG.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ func PageRenderAndUpload(v1 *viper.Viper, mc *minio.Client, timeout time.Duratio

jsonlds, err := PageRender(v1, timeout, url, k, repologger, repoStats)

if err != nil { // from page render
if err == nil { // from page render. If there are no errros, upload.
if len(jsonlds) > 1 {
repologger.WithFields(log.Fields{"url": url, "issue": "Multiple JSON"}).Debug(err)
log.WithFields(log.Fields{"url": url, "issue": "Multiple JSON"}).Info("Error uploading jsonld to object store:", url)
repologger.WithFields(log.Fields{"url": url, "issue": "Multiple JSON"}).Debug()
}
for _, jsonld := range jsonlds {
sha, err := Upload(v1, mc, bucketName, k, url, jsonld)
Expand All @@ -175,6 +176,7 @@ func PageRenderAndUpload(v1 *viper.Viper, mc *minio.Client, timeout time.Duratio
repologger.WithFields(log.Fields{"url": url, "sha": sha, "issue": "Error uploading jsonld to object store"}).Error(err)
repoStats.Inc(common.StoreError)
} else {
log.WithFields(log.Fields{"url": url, "sha": sha, "issue": "Uploaded JSONLD to object store"}).Info("Uploaded JSONLD to object store:", url, err, sha)
repologger.WithFields(log.Fields{"url": url, "sha": sha, "issue": "Uploaded JSONLD to object store"}).Debug()
repoStats.Inc(common.Stored)
}
Expand All @@ -198,6 +200,7 @@ func PageRender(v1 *viper.Viper, timeout time.Duration, url, k string, repologge
sources, err := configTypes.GetSources(v1)
source, err := configTypes.GetSourceByName(sources, k)
headlessWait := source.HeadlessWait

if timeout*time.Duration(retries) < time.Duration(headlessWait)*time.Second {
timeout = time.Duration(headlessWait) * time.Second
}
Expand Down Expand Up @@ -389,24 +392,8 @@ func PageRender(v1 *viper.Viper, timeout time.Duration, url, k string, repologge
} else if valid && jsonld != "" { // traps out the root domain... should do this different
response = append(response, jsonld)
err = nil
//sha, err := Upload(v1, mc, bucketName, k, url, jsonld)
//if err != nil {
// log.WithFields(log.Fields{"url": url, "sha": sha, "issue": "Error uploading jsonld to object store"}).Error("Error uploading jsonld to object store:", url, err, sha)
// repologger.WithFields(log.Fields{"url": url, "sha": sha, "issue": "Error uploading jsonld to object store"}).Error(err)
// repoStats.Inc(common.StoreError)
//} else {
// repologger.WithFields(log.Fields{"url": url, "sha": sha, "issue": "Uploaded JSONLD to object store"}).Debug()
// repoStats.Inc(common.Stored)
//}
//// TODO Is here where to add an entry to the KV store
//err = db.Update(func(tx *bolt.Tx) error {
// b := tx.Bucket([]byte(k))
// err := b.Put([]byte(url), []byte(sha))
// if err != nil {
// log.Error("Error writing to bolt", err)
// }
// return nil
//})
// need to just return a list

} else {
// there could be one bad jsonld, and one good. We want to process the jsonld
// so, do not set an err
Expand Down
1 change: 1 addition & 0 deletions internal/summoner/summoner.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func Summoner(mc *minio.Client, v1 *viper.Viper, db *bolt.DB) {
}
// just report the error, and then run gathered urls
if len(hru) > 0 {
log.Info("running headless:")
acquire.HeadlessNG(v1, mc, hru, db, runStats)
}

Expand Down
39 changes: 39 additions & 0 deletions pkg/cli/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cli

import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

// gleanerCmd represents the run command
var versionCmd = &cobra.Command{
Use: "version",
TraverseChildren: true,
Short: "returns version ",
Long: `returns version
`, PersistentPreRun: func(cmd *cobra.Command, args []string) {
initGleanerConfig()
},
Run: func(cmd *cobra.Command, args []string) {
log.Info("gleaner called")
log.Info("gleaner called")

},
}

func init() {
rootCmd.AddCommand(versionCmd)
// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// gleanerCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// gleanerCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

func returnVersion() {
log.Println("Version")
}

0 comments on commit 1e08c39

Please sign in to comment.