mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: generate static directory
This commit is contained in:
4 files changed
+35
-2
No files matched your search
@@ -93,6 +93,12 @@ export async function apply(ctx: Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const f of global.addons) {
|
||||
const dir = path.join(f, 'public');
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
if (await fs.pathExists(dir)) await fs.copy(dir, '/root/.hydro/static');
|
||||
}
|
||||
await ctx.parallel('app/listen');
|
||||
logger.success('Server started');
|
||||
process.send?.('ready');
|
||||
await ctx.parallel('app/ready');
|
||||
|
||||
@@ -32,6 +32,7 @@ type HandlerEvents =
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export interface EventMap extends LifecycleEvents, HandlerEvents {
|
||||
'app/started': () => void
|
||||
'app/listen': () => void
|
||||
'app/ready': () => VoidReturn
|
||||
'app/exit': () => VoidReturn
|
||||
'app/before-reload': (entries: Set<string>) => VoidReturn
|
||||
|
||||
@@ -556,7 +556,7 @@ ${ctx.response.status} ${endTime - startTime}ms ${ctx.response.length}`);
|
||||
socket.close();
|
||||
});
|
||||
const port = system.get('server.port');
|
||||
pluginContext.on('app/ready', async () => {
|
||||
pluginContext.on('app/listen', async () => {
|
||||
await new Promise((r) => {
|
||||
httpServer.listen(argv.options.port || port, () => {
|
||||
logger.success('Server listening at: %d', argv.options.port || port);
|
||||
|
||||
Reference in new issue
Block a user