Allow configuring the port and folder to be configured with env variables
parent
62330c5f07
commit
863b92df6a
|
@ -12,11 +12,25 @@ import { DiskSpacePrimitives } from "../common/spaces/disk_space_primitives.ts";
|
||||||
import { SpacePrimitives } from "../common/spaces/space_primitives.ts";
|
import { SpacePrimitives } from "../common/spaces/space_primitives.ts";
|
||||||
import { S3SpacePrimitives } from "../server/spaces/s3_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 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;
|
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(
|
console.log(
|
||||||
"Going to start SilverBullet binding to",
|
"Going to start SilverBullet binding to",
|
||||||
`${hostname}:${port}`,
|
`${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,
|
port: port,
|
||||||
pagesPath: folder,
|
pagesPath: folder,
|
||||||
clientAssetBundle: new AssetBundle(clientAssetBundle as AssetJson),
|
clientAssetBundle: new AssetBundle(clientAssetBundle as AssetJson),
|
||||||
user: options.user,
|
user: options.user ?? Deno.env.get("SB_USER"),
|
||||||
keyFile: options.key,
|
keyFile: options.key,
|
||||||
certFile: options.cert,
|
certFile: options.cert,
|
||||||
maxFileSizeMB: +maxFileSizeMB,
|
maxFileSizeMB: +maxFileSizeMB,
|
||||||
|
|
|
@ -17,7 +17,7 @@ await new Command()
|
||||||
})
|
})
|
||||||
.usage("<options> <folder> | <command> (see below)")
|
.usage("<options> <folder> | <command> (see below)")
|
||||||
// Main command
|
// Main command
|
||||||
.arguments("<folder:string>")
|
.arguments("[folder:string]")
|
||||||
.option(
|
.option(
|
||||||
"--hostname, -L <hostname:string>",
|
"--hostname, -L <hostname:string>",
|
||||||
"Hostname or address to listen on",
|
"Hostname or address to listen on",
|
||||||
|
|
|
@ -19,7 +19,7 @@ This consists of two steps (unless Deno is already installed — in which case w
|
||||||
With Deno installed, run:
|
With Deno installed, run:
|
||||||
|
|
||||||
```shell
|
```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).
|
This will install `silverbullet` into your `~/.deno/bin` folder (which should already be in your `$PATH` if you followed the Deno install instructions).
|
||||||
|
|
Loading…
Reference in New Issue