mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-27 05:56:21 +00:00
feat: allow cockpit with docker
This commit is contained in:
parent
2505fa5284
commit
8efa8895aa
@ -1,11 +1,12 @@
|
|||||||
import { Embark } from "../../../typings/embark";
|
import {Embark} from "../../../typings/embark";
|
||||||
import {canonicalHost} from "../../utils/host.js";
|
import {dockerHostSwap} from "../../utils/host.js";
|
||||||
import {findNextPort} from "../../utils/network";
|
import {findNextPort} from "../../utils/network";
|
||||||
import Server from "./server";
|
import Server from "./server";
|
||||||
|
|
||||||
const utils = require("../../utils/utils.js");
|
const utils = require("../../utils/utils.js");
|
||||||
|
|
||||||
const DEFAULT_PORT = 55555;
|
const DEFAULT_PORT = 55555;
|
||||||
|
const DEFAULT_HOSTNAME = "localhost";
|
||||||
|
|
||||||
export default class Api {
|
export default class Api {
|
||||||
private port!: number;
|
private port!: number;
|
||||||
@ -16,9 +17,9 @@ export default class Api {
|
|||||||
this.embark.events.emit("status", __("Starting API"));
|
this.embark.events.emit("status", __("Starting API"));
|
||||||
findNextPort(DEFAULT_PORT).then((port) => {
|
findNextPort(DEFAULT_PORT).then((port) => {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.apiUrl = "http://" + canonicalHost("127.0.0.1") + ":" + this.port;
|
this.apiUrl = `http://${DEFAULT_HOSTNAME}:${this.port}`;
|
||||||
|
|
||||||
this.api = new Server(this.embark, this.port, options.plugins);
|
this.api = new Server(this.embark, this.port, dockerHostSwap(DEFAULT_HOSTNAME), options.plugins);
|
||||||
|
|
||||||
this.listenToCommands();
|
this.listenToCommands();
|
||||||
this.registerConsoleCommands();
|
this.registerConsoleCommands();
|
||||||
|
@ -22,7 +22,7 @@ export default class Server {
|
|||||||
private expressInstance: expressWs.Instance;
|
private expressInstance: expressWs.Instance;
|
||||||
private server?: http.Server;
|
private server?: http.Server;
|
||||||
|
|
||||||
constructor(private embark: Embark, private port: number, private plugins: Plugins) {
|
constructor(private embark: Embark, private port: number, private hostname: string, private plugins: Plugins) {
|
||||||
this.expressInstance = this.initApp();
|
this.expressInstance = this.initApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export default class Server {
|
|||||||
return reject(new Error(message));
|
return reject(new Error(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.server = this.expressInstance.app.listen(this.port, () => {
|
this.server = this.expressInstance.app.listen(this.port, this.hostname, () => {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user