forked from defunkt/toes
Add app publish/unpublish lifecycle hooks
This commit is contained in:
parent
c0276389eb
commit
875c89de18
|
|
@ -168,6 +168,8 @@ export function registerApp(dir: string) {
|
|||
emit({ type: 'app:create', app: dir })
|
||||
if (!error && !isStatic) {
|
||||
runApp(dir, getPort(dir))
|
||||
} else if (isStatic) {
|
||||
publishApp(dir)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -238,6 +240,7 @@ export function startApp(dir: string) {
|
|||
app.manuallyStopped = false
|
||||
update()
|
||||
emit({ type: 'app:start', app: dir })
|
||||
publishApp(dir)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -294,6 +297,7 @@ export function stopApp(dir: string) {
|
|||
app.state = 'stopped'
|
||||
app.started = undefined
|
||||
app.manuallyStopped = true
|
||||
unpublishApp(dir)
|
||||
update()
|
||||
emit({ type: 'app:stop', app: dir })
|
||||
return
|
||||
|
|
@ -391,7 +395,10 @@ function discoverApps() {
|
|||
const isStatic = !!pkg.toes?.static
|
||||
const state: AppState = error ? 'invalid' : (isStatic ? 'running' : 'stopped')
|
||||
const app = buildApp(dir, pkg, state, error)
|
||||
if (isStatic) app.started = Date.now()
|
||||
if (isStatic) {
|
||||
app.started = Date.now()
|
||||
publishApp(dir)
|
||||
}
|
||||
_apps.set(dir, app)
|
||||
}
|
||||
update()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user