MCPcopy
hub / github.com/perkeep/perkeep / RunCommand

Method RunCommand

dev/devcam/server.go:507–576  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

505}
506
507func (c *serverCmd) RunCommand(args []string) error {
508 err := c.checkFlags(args)
509 if err != nil {
510 return cmdmain.UsageError(fmt.Sprint(err))
511 }
512 if !*noBuild {
513 targets := []string{
514 filepath.Join("server", "perkeepd"),
515 filepath.Join("cmd", "pk"),
516 }
517 if c.hello {
518 targets = append(targets, "app/hello")
519 }
520 if c.publish {
521 targets = append(targets, "app/publisher")
522 }
523 targets = append(targets, "app/scanningcabinet")
524 err := build(targets...)
525 if err != nil {
526 return err
527 }
528 }
529 if err := c.setRoot(); err != nil {
530 return fmt.Errorf("Could not setup the camli root: %v", err)
531 }
532 if err := c.setEnvVars(); err != nil {
533 return fmt.Errorf("Could not setup the env vars: %v", err)
534 }
535 // wipeCacheDir needs to be called after setEnvVars, because that is where
536 // CAMLI_CACHE_DIR is defined.
537 if *wipeCache {
538 c.env.wipeCacheDir()
539 }
540 if err := c.setupIndexer(); err != nil {
541 return fmt.Errorf("Could not setup the indexer: %v", err)
542 }
543 if err := c.syncTemplateBlobs(); err != nil {
544 return fmt.Errorf("Could not copy the template blobs: %v", err)
545 }
546 if err := c.setFullClosure(); err != nil {
547 return fmt.Errorf("Could not setup the closure lib: %v", err)
548 }
549
550 log.Printf("Starting dev server on %v/ui/ with password \"pass3179\"\n",
551 c.env.m["CAMLI_BASEURL"])
552
553 pkBin, err := exec.LookPath("perkeepd")
554 if err != nil {
555 return fmt.Errorf("could not find perkeepd path: %v", err)
556 }
557 cmdArgs := []string{
558 "-configfile=" + filepath.Join(camliSrcRoot, "config", "dev-server-config.json"),
559 "-listen=" + c.listen,
560 "-openbrowser=" + strconv.FormatBool(c.openBrowser),
561 }
562 if c.extraArgs != "" {
563 cmdArgs = append(cmdArgs, strings.Split(c.extraArgs, ",")...)
564 }

Callers

nothing calls this directly

Calls 14

checkFlagsMethod · 0.95
setRootMethod · 0.95
setEnvVarsMethod · 0.95
setupIndexerMethod · 0.95
syncTemplateBlobsMethod · 0.95
setFullClosureMethod · 0.95
makeThingsMethod · 0.95
UsageErrorTypeAlias · 0.92
wipeCacheDirMethod · 0.80
PrintfMethod · 0.80
buildFunction · 0.70
runExecFunction · 0.70

Tested by

no test coverage detected