Documentation ¶
Overview ¶
Installing ¶
This package is a single binary which combines all of the binaries shipped with the daemon system into one simple package and you can run the servers using subcommand arguments.
sudo go install ask.systems/daemon@latest
You want to install it as root because you will run spawn as root so it is best for security to make the binary owned by root, otherwise the user that owns the binary could edit it and run any code as root. The easiest way to do this and allow for updating daemon is to just run go install as root.
If you run spawn with no arguments it will create the example config and run portal plus the dashboard. If you want to just print the example config run:
daemon spawn -example_config
For more info read the README! Expand it above on the go docs site.
Making custom go servers ¶
For servers written in go, you can use the portal client library ask.systems/daemon/portal/gate to register with portal, automatically select a port to listen on that won't conflict and even automatically use a newly generated TLS certificate to encrypt local traffic (this time it's easy!). To do this you will call ask.systems/daemon/portal/gate.StartTLSRegistration, set up any application handlers with net/http.Handle then call ask.systems/daemon/tools.RunHTTPServerTLS.
The easiest way to configure access to portal registration RPCs is via the environment variables PORTAL_ADDR and PORTAL_TOKEN. You can find the portal token printed in the portal logs on startup. If you set the portal flags on spawn it will propegate them to child processes with thes env vars, and you can set them up in your shell dotfiles. You can also import _ ask.systems/daemon/portal/flags if you'd like to configure the portal address and token with flags instead of the environment variables.
Make sure to take a look at the other utility functions in ask.systems/daemon/tools too! There's a second flags flags package which provides the version stamp flag and the syslog support via the log package: ask.systems/daemon/tools/flags.
Take a look at the package example for the client library ask.systems/daemon/portal/gate for a simple go client of portal with encrypted internal traffic. It uses the standard net/http.Handle system. The source code of ask.systems/daemon/host is a good basic server example too.
You can then sudo go install your own binary (or copy your binary to /root/) and add an entry to your config.pbtxt with binary name and arguments. By default spawn checks the working dir for binaries named in the config and you can set the spawn -path argument to change it.
Megabinary ¶
The way it works is each of the individual binaries in daemon have all of their code packed into the <bin>/embed<bin> packages. Each of them have a standard Run function that accepts commandline arguments. Then the packages you actually install, such as ask.systems/daemon/assimilate or ask.systems/daemon have a simple main function that just calls the Run function from the appropriate embed package.
If you would like to, you can use the public interfaces in the embed packages for your applications as well, if you would like to for example embed a copy of ask.systems/daemon/host instead of calling the helper functions in ask.systems/daemon/tools (which cover pretty much all of host's functionality).
Also if you rename the ask.systems/daemon binary to one of the subcommands, it will act as if it just that individual binary. Spawn actually uses this when copying the megabinary to chroots so it will show in your process list and syslog as the correct name.
Directories ¶
Path | Synopsis |
---|---|
Assimilate registers paths with portal on behalf of third-party HTTP servers that listen on a fixed port.
|
Assimilate registers paths with portal on behalf of third-party HTTP servers that listen on a fixed port. |
embedassimilate
Embedassimilate lets you run the assimilate binary main function inside another program
|
Embedassimilate lets you run the assimilate binary main function inside another program |
Host is a basic file server suitable for hosting static websites using portal.
|
Host is a basic file server suitable for hosting static websites using portal. |
embedhost
Embedhost lets you run the host binary main function inside another program
|
Embedhost lets you run the host binary main function inside another program |
Portal is a reverse proxy HTTPS server configured via gRPC
|
Portal is a reverse proxy HTTPS server configured via gRPC |
embedportal
Embedportal lets you run the portal binary main function inside another program
|
Embedportal lets you run the portal binary main function inside another program |
flags
Defines the -portal_addr and -portal_token flags
|
Defines the -portal_addr and -portal_token flags |
gate
The client library for registering paths with ask.systems/daemon/portal.
|
The client library for registering paths with ask.systems/daemon/portal. |
Spawn is a launcher with a web dashboard that runs commands with arguments listed in the [textproto] config.pbtxt file.
|
Spawn is a launcher with a web dashboard that runs commands with arguments listed in the [textproto] config.pbtxt file. |
embedspawn
Embedspawn lets you run the spawn binary main function inside another program
|
Embedspawn lets you run the spawn binary main function inside another program |
Tools provides utility functions useful for web servers
|
Tools provides utility functions useful for web servers |
flags
Import this package to get useful flags every server should have
|
Import this package to get useful flags every server should have |