-
-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: complete the design of instance constroller
- Loading branch information
Showing
20 changed files
with
7,912 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# node_modules | ||
.env | ||
ecosystem.config.js | ||
# dist | ||
data | ||
src | ||
tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
node_modules | ||
dist | ||
|
||
upload | ||
data/* | ||
tmp | ||
|
||
.env | ||
.env.local | ||
|
||
ecosystem.config.js | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM node:16-alpine | ||
|
||
|
||
EXPOSE 9000 | ||
WORKDIR /app | ||
ENV LOG_LEVEL=debug | ||
COPY . /app | ||
# RUN npm i | ||
# RUN npm run build | ||
USER node | ||
CMD [ "npm", "run", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
|
||
# laf service controller | ||
|
||
|
||
### Application instance status | ||
```ts | ||
export enum ApplicationInstanceStatus { | ||
CREATED = 'created', | ||
PREPARED_START = 'prepared_start', | ||
STARTING = 'starting', | ||
RUNNING = 'running', | ||
PREPARED_STOP = 'prepared_stop', | ||
STOPPING = 'stopping', | ||
STOPPED = 'stopped', | ||
PREPARED_RESTART = 'prepared_restart', | ||
RESTARTING = 'restarting' | ||
} | ||
|
||
``` | ||
|
||
### instance status machine | ||
|
||
`created`: nop | ||
|
||
`prepared_start`: | ||
-> loop apps in `prepared_start` | ||
-> start app instance for each | ||
-> update app status to `starting` | ||
|
||
`starting`: | ||
-> loop apps in `starting` | ||
-> get instance status for each app | ||
-> update running app status to `running` | ||
|
||
`running`: nop | ||
|
||
`prepared_stop`: | ||
-> loop apps in `prepared_stop` | ||
-> stop app instance for each | ||
-> update app status to `stopping` | ||
|
||
`stopping`: | ||
-> loop apps in `stopping` | ||
-> get instance status for each app | ||
-> update stopped app status to `stopped` | ||
|
||
`stopped`: nop | ||
|
||
`prepared_restart`: | ||
-> loop apps in `prepared_restart` | ||
-> stop app instance for each | ||
-> update app status to `restarting` | ||
|
||
`restarting`: | ||
-> loop apps in `restarting` | ||
-> get instance status for each app | ||
-> start stopped app & update app status to `starting` | ||
|
||
|
||
### scheduler logic design | ||
|
||
- set a timer to execute schedular loop | ||
- call each handlers in loop: | ||
- `prepared_start` handler | ||
- `starting` handler | ||
- `prepared_stop` handler | ||
- `stopping` handler | ||
- `prepared_restart` handler | ||
- `restarting` handler |
Oops, something went wrong.