blog-bs/.cracorc.js

24 lines
704 B
JavaScript
Raw Normal View History

2021-10-31 15:08:34 +08:00
const { ServiceRegister } = require("@fennec/configuration");
const { findFreePorts } = require("find-free-ports");
module.exports = async function () {
return {
devServer: {
open: false,
port: await findFreePorts().then((ports) => ports[0]),
onListening(devServer) {
if (!devServer) {
throw new Error("webpack-dev-server is not defined");
}
const port = devServer.listeningApp.address().port;
const register = new ServiceRegister({
etcd: { hosts: ["http://rpi:2379"] },
});
register.register("admin.blog", `http://localhost:${port}/`);
console.log("Listening on port:", port);
},
},
};
};