Index | Files

package serverinit

import ""

Package serverinit is responsible for mapping from a Perkeep configuration file and instantiating HTTP Handlers for all the necessary endpoints.


Package Files

devmode.go env.go genconfig.go serverinit.go


const (
    // CamliNetDNS is the hostname of the DNS server.
    CamliNetDNS = ""
    // CamliNetDomain is the domain name. It is relevant to
    // Perkeep, because a deployment through the Perkeep on Google Cloud launcher
    // automatically offers a subdomain name in this domain to any instance.
    CamliNetDomain = ""

For getting a name in


var ErrCamliPath = errors.New("invalid Perkeep request path")

func WriteDefaultConfigFile Uses

func WriteDefaultConfigFile(filePath string, useSQLite bool) error

WriteDefaultConfigFile generates a new default high-level server configuration file at filePath. If useSQLite, the default indexer will use SQLite, otherwise leveldb. If filePath already exists, it is overwritten.

type Config Uses

type Config struct {
    // contains filtered or unexported fields

A Config is the wrapper around a Perkeep JSON configuration file. Files on disk can be in either high-level or low-level format, but the Load function always returns the Config in its low-level format (a.k.a. the "handler" format).

TODO(bradfitz): document and/or link to the low-level format; for now you can see the high-level config format at and the the low-level format by running "camtool dumpconfig".

func DefaultEnvConfig Uses

func DefaultEnvConfig() (*Config, error)

DefaultEnvConfig returns the default configuration when running on a known environment. Currently this just includes Google Compute Engine. If the environment isn't known (nil, nil) is returned.

func Load Uses

func Load(config []byte) (*Config, error)

Load returns a low-level "handler config" from the provided config. If the config doesn't contain a top-level JSON key of "handlerConfig" with boolean value true, the configuration is assumed to be a high-level "user config" file, and transformed into a low-level config.

func LoadFile Uses

func LoadFile(filename string) (*Config, error)

LoadFile returns a low-level "handler config" from the provided filename. If the config file doesn't contain a top-level JSON key of "handlerConfig" with boolean value true, the configuration is assumed to be a high-level "user config" file, and transformed into a low-level config.

func (*Config) AppURL Uses

func (c *Config) AppURL() map[string]string

AppURL returns a map of app name to app base URL for all the configured server apps.

func (*Config) BaseURL Uses

func (c *Config) BaseURL() string

BaseURL returns the optional URL prefix listening the root of this server. It does not end in a trailing slash.

func (*Config) CamliNetIP Uses

func (c *Config) CamliNetIP() string

CamliNetIP returns the optional IP address that this server can be reached out. If set in the config, the server will request a DNS subdomain name from the Perkeep DNS server.

func (*Config) HTTPS Uses

func (c *Config) HTTPS() bool

HTTPS reports whether this configuration wants to serve HTTPS.

func (*Config) HTTPSCert Uses

func (c *Config) HTTPSCert() string

HTTPSCert returns the optional path to an HTTPS public key certificate file.

func (*Config) HTTPSKey Uses

func (c *Config) HTTPSKey() string

HTTPSKey returns the optional path to an HTTPS private key file.

func (*Config) InstallHandlers Uses

func (c *Config) InstallHandlers(hi HandlerInstaller, baseURL string) (shutdown io.Closer, err error)

InstallHandlers creates and registers all the HTTP Handlers needed by config into the provided HandlerInstaller and validates that the configuration is valid.

baseURL is required and specifies the root of this webserver, without trailing slash.

The returned shutdown value can be used to cleanly shut down the handlers.

func (*Config) KeyRingAndId Uses

func (c *Config) KeyRingAndId() (keyRing, keyId string, err error)

KeyRingAndId returns the GPG identity keyring path and the user's GPG keyID (TODO: length/case), if configured. TODO: which error value if not configured?

func (*Config) ListenAddr Uses

func (c *Config) ListenAddr() string

ListenAddr returns the optional configured listen address in ":port" or "ip:port" form.

func (*Config) LowLevelJSONConfig Uses

func (c *Config) LowLevelJSONConfig() map[string]interface{}

LowLevelJSONConfig returns the config's underlying low-level JSON form for debugging.

Deprecated: this is provided for debugging only and will be going away as the move to TOML-based configuration progresses. Do not depend on this.

func (*Config) SetKeepGoing Uses

func (c *Config) SetKeepGoing(v bool)

SetKeepGoing changes each configured prefix to set "keepGoing" to true. This indicates that validation, reindexing, or recovery behavior should not cause the process to end.

func (*Config) SetReindex Uses

func (c *Config) SetReindex(v bool)

func (*Config) StartApps Uses

func (c *Config) StartApps() error

StartApps starts all the server applications that were configured during InstallHandlers. It should only be called after perkeepd has started serving, since these apps might request some configuration from Perkeep to finish initializing.

func (*Config) UIPath Uses

func (c *Config) UIPath() string

UIPath returns the relative path to the server's user interface handler, if the UI is configured. Otherwise it returns the empty string. It is not valid until after a call to InstallHandlers

If non-empty, the returned value will both begin and end with a slash.

func (*Config) UploadPublicKey Uses

func (c *Config) UploadPublicKey(ctx context.Context) error

UploadPublicKey uploads the public key blob with the sign handler that was configured during InstallHandlers.

type HandlerInstaller Uses

type HandlerInstaller interface {
    Handle(path string, h http.Handler)

A HandlerInstaller is anything that can register an HTTP Handler at a prefix path. Both *http.ServeMux and implement HandlerInstaller.

Package serverinit imports 41 packages (graph) and is imported by 2 packages. Updated 2019-06-16. Refresh now. Tools for package owners.