Skip to content

Commit

Permalink
Merge pull request #97 from hoobs-org/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
mkellsy authored Jul 29, 2021
2 parents 35b7f0f + 3a92d96 commit d4599b0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hoobsd",
"version": "4.0.93",
"version": "4.0.98",
"description": "Server component for the certified HOOBS smart home stack.",
"license": "GPL-3.0",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions src/hub/controllers/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default class StatusController {
version: applications.hoobsd?.hoobsd_version,
current: applications.hoobsd?.hoobsd_current,
upgraded: applications.hoobsd?.hoobsd_upgraded,
repo: system.repo,
cli_version: applications.cli?.cli_version,
cli_current: applications.cli?.cli_current,
cli_upgraded: applications.cli?.cli_upgraded,
Expand Down
17 changes: 12 additions & 5 deletions src/hub/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import ThemesController from "./controllers/themes";
import WeatherController from "./controllers/weather";

const BRIDGE_LAUNCH_DELAY = 1 * 1000;
const BRIDGE_TEARDOWN_DELAY = 2 * 1000;
const BRIDGE_TEARDOWN_DELAY = 3 * 1000;
const BRIDGE_RELAUNCH_DELAY = 7 * 1000;

function running(pid: number): boolean {
Expand Down Expand Up @@ -202,9 +202,17 @@ export default class API extends EventEmitter {
new ThemesController();
new WeatherController();

State.app?.use("/", Express.static(existsSync(this.settings.gui_path || "/usr/lib/hoobs") ? this.settings.gui_path || "/usr/lib/hoobs" : Path.join(__dirname, "../static")));
State.app?.use("/touch", Express.static(existsSync(this.settings.touch_path || "/usr/lib/hoobs-touch") ? this.settings.touch_path || "/usr/lib/hoobs-touch" : Path.join(__dirname, "../static")));
State.app?.use("/themes", Express.static(Paths.themes));
State.app?.use("/", Express.static(existsSync(this.settings.gui_path || "/usr/lib/hoobs") ? this.settings.gui_path || "/usr/lib/hoobs" : Path.join(__dirname, "../static"), {
setHeaders: (response) => { response.setHeader("cache-control", "public, max-age=1209600000"); },
}));

State.app?.use("/touch", Express.static(existsSync(this.settings.touch_path || "/usr/lib/hoobs-touch") ? this.settings.touch_path || "/usr/lib/hoobs-touch" : Path.join(__dirname, "../static"), {
setHeaders: (response) => { response.setHeader("cache-control", "public, max-age=1209600000"); },
}));

State.app?.use("/themes", Express.static(Paths.themes, {
setHeaders: (response) => { response.setHeader("cache-control", "public, max-age=0"); },
}));

State.app?.use("/backups", Express.static(Paths.backups, {
setHeaders: (response, path) => {
Expand Down Expand Up @@ -430,7 +438,6 @@ export default class API extends EventEmitter {
}

System.kill(ProcessQuery.PORT, this.port);
System.preload();

this.listner?.listen(this.port, () => {
this.time = new Date().getTime();
Expand Down
2 changes: 1 addition & 1 deletion src/hub/services/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default async function Plugin(request: Request, response: Response, next:

for (let i = 0; i < State.bridges.length; i += 1) {
if (State.bridges[i].type !== "hub") {
const plugin: { [key: string]: any } | undefined = Plugins.load(State.bridges[i].id).find((item) => item.identifier === identifier);
const plugin: { [key: string]: any } | undefined = Plugins.load(State.bridges[i].id, State.bridges[i].type === "dev").find((item) => item.identifier === identifier);

if (plugin) {
const sidecars = Paths.loadJson<{ [key: string]: string }>(join(Paths.data(State.bridges[i].id), "sidecars.json"), {});
Expand Down
7 changes: 4 additions & 3 deletions src/services/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ export default class Plugins {
if (cached) return cached;

const results: { [key: string]: any }[] = [];
const record = development ? State.bridges.find((item) => item.id === bridge) : undefined;

if (development) {
const pjson = Plugins.loadPackage(State.project || "") || {};
if (development && record) {
const pjson = Plugins.loadPackage(record.project || "") || {};

results.push({
identifier: pjson.name,
name: PluginManager.extractPluginName(pjson.name),
scope: PluginManager.extractPluginScope(pjson.name),
directory: State.project,
directory: record.project,
pjson,
library: pjson.main || "./index.js",
});
Expand Down
16 changes: 0 additions & 16 deletions src/services/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,6 @@ export const enum LedStatus {
}

export default class System {
static preload(): void {
System.info();

System.cli.info(true);
System.cli.info(false);

System.gui.info(true);
System.gui.info(false);

System.hoobsd.info(true);
System.hoobsd.info(false);

System.runtime.info(true);
System.runtime.info(false);
}

static led(status: LedStatus) {
if (existsSync("/sys/class/leds/led0/brightness") && existsSync("/sys/class/leds/led1/brightness")) {
switch (status) {
Expand Down

0 comments on commit d4599b0

Please sign in to comment.