Allow configuring the port and folder to be configured with env variables

pull/417/head
Zef Hemel 2023-05-24 05:42:02 +02:00
parent 62330c5f07
commit 863b92df6a
3 changed files with 19 additions and 5 deletions

View File

@ -12,11 +12,25 @@ import { DiskSpacePrimitives } from "../common/spaces/disk_space_primitives.ts";
import { SpacePrimitives } from "../common/spaces/space_primitives.ts";
import { S3SpacePrimitives } from "../server/spaces/s3_space_primitives.ts";
export function serveCommand(options: any, folder: string) {
export function serveCommand(
options: any,
folder?: string,
) {
const hostname = options.hostname || "127.0.0.1";
const port = options.port || 3000;
const port = options.port ||
(Deno.env.get("SB_PORT") && +Deno.env.get("SB_PORT")!) || 3000;
const maxFileSizeMB = options.maxFileSizeMB || 20;
if (!folder) {
folder = Deno.env.get("SB_FOLDER");
if (!folder) {
console.error(
"No folder specified. Please pass a folder as an argument or set SB_FOLDER environment variable.",
);
Deno.exit(1);
}
}
console.log(
"Going to start SilverBullet binding to",
`${hostname}:${port}`,
@ -56,7 +70,7 @@ To allow outside connections, pass -L 0.0.0.0 as a flag, and put a TLS terminato
port: port,
pagesPath: folder,
clientAssetBundle: new AssetBundle(clientAssetBundle as AssetJson),
user: options.user,
user: options.user ?? Deno.env.get("SB_USER"),
keyFile: options.key,
certFile: options.cert,
maxFileSizeMB: +maxFileSizeMB,

View File

@ -17,7 +17,7 @@ await new Command()
})
.usage("<options> <folder> | <command> (see below)")
// Main command
.arguments("<folder:string>")
.arguments("[folder:string]")
.option(
"--hostname, -L <hostname:string>",
"Hostname or address to listen on",

View File

@ -19,7 +19,7 @@ This consists of two steps (unless Deno is already installed — in which case w
With Deno installed, run:
```shell
deno install -f --name silverbullet -A https://silverbullet.md/silverbullet.js
deno install -f --name silverbullet -A https://get.silverbullet.md
```
This will install `silverbullet` into your `~/.deno/bin` folder (which should already be in your `$PATH` if you followed the Deno install instructions).