Skip to content

Commit

Permalink
Merge pull request Tencent#69 from TabSpace/master
Browse files Browse the repository at this point in the history
feat: deno 应用进程改为默认使用 denon 来管理
  • Loading branch information
binggg authored Aug 19, 2020
2 parents 6c53afc + dcbde2f commit 8b9f12d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
16 changes: 14 additions & 2 deletions packages/framework-plugin-deno/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,21 @@ cloudbase framework:deploy

选填,入口文件,字符串格式,默认值 `'entry.ts'`

### `runOptions`
## 关于 denon

选填,Deno 执行选项,字符串数组格式,默认值 `['--allow-all']`
服务使用 [denon](https://github.com/denosaurs/denon) 来管理 deno 进程,以便于管理 deno 启动参数

```yml
# denon.yml
allow:
- net
- env

scripts:
start: deno run entry.ts
```
`cloudbase init` 之后会自动提供一个默认的 denon.yml,请根据应用需求来修改

## 更多插件

Expand Down
6 changes: 3 additions & 3 deletions packages/framework-plugin-deno/assets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ ENV DENO_DIR="/root/.cache/deno"
ENV DENO_INSTALL="/root/.deno"
ENV PATH="$DENO_INSTALL/bin:$PATH"
ENV PORT=80

EXPOSE 80
ENTRYPOINT ["deno"]

WORKDIR /usr/src/app
COPY . .
RUN deno install --allow-read --allow-run --allow-write --allow-net -f -q --unstable https://deno.land/x/denon/denon.ts
RUN deno install <%= entry %>

CMD ["run", <%- denoRunOptions %>, "<%= entry %>"]
ENTRYPOINT ["denon"]
CMD ["start"]
11 changes: 0 additions & 11 deletions packages/framework-plugin-deno/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ interface BuilderBuildOptions {
runtime?: string;
// 启动入口文件
entry?: string;
// 启动参数
runOptions?: Array<string>;
// 路径
path: string;
// 服务名
Expand Down Expand Up @@ -43,15 +41,6 @@ export class DenoBuilder extends Builder {
spec.denoVersion = `-s ${spec.runtime}`
}

spec.denoRunOptions = '';
if (!spec.runOptions || spec.runOptions.length <= 0) {
spec.denoRunOptions = '"--allow-env",'
} else {
spec.denoRunOptions = spec.runOptions.map((option:string) => {
return `"${option}"`;
}).join(',')
}

fs.ensureDirSync(appDir);

await Promise.all([
Expand Down
4 changes: 1 addition & 3 deletions packages/framework-plugin-deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ class DenoPlugin extends Plugin {

const DEFAULT_INPUTS = {
dockerImage: 'debian:buster-slim',
// example: v1.2.0
// runtime example: v1.2.0
runtime: 'latest',
entry: 'entry.ts',
runOptions: ['--allow-all'],
serviceName: 'deno-app',
servicePath: '/deno-app',
projectPath: '.',
Expand Down Expand Up @@ -63,7 +62,6 @@ class DenoPlugin extends Plugin {
dockerImage: this.resolvedInputs.dockerImage,
runtime: this.resolvedInputs.runtime,
entry: this.resolvedInputs.entry,
runOptions: this.resolvedInputs.runOptions,
name: this.resolvedInputs.serviceName || 'deno-app',
path: this.resolvedInputs.servicePath || '/deno-app',
}
Expand Down

0 comments on commit 8b9f12d

Please sign in to comment.