@@ -81,8 +81,7 @@ export class DockerProcessAdapter extends EventEmitter implements IInstanceProce
8181 public async destroy ( ) {
8282 try {
8383 await this . container . remove ( ) ;
84- } catch ( error ) {
85- }
84+ } catch ( error ) { }
8685 }
8786
8887 private wait ( ) {
@@ -99,10 +98,8 @@ export default class DockerStartCommand extends InstanceCommand {
9998 }
10099
101100 async exec ( instance : Instance , source = "Unknown" ) {
102- if ( ! instance . config . startCommand || ! instance . config . cwd || ! instance . config . ie || ! instance . config . oe )
103- return instance . failure ( new StartupDockerProcessError ( "启动命令,输入输出编码或工作目录为空值" ) ) ;
104- if ( ! fs . existsSync ( instance . absoluteCwdPath ( ) ) )
105- return instance . failure ( new StartupDockerProcessError ( "工作目录并不存在" ) ) ;
101+ if ( ! instance . config . startCommand || ! instance . config . cwd || ! instance . config . ie || ! instance . config . oe ) return instance . failure ( new StartupDockerProcessError ( "启动命令,输入输出编码或工作目录为空值" ) ) ;
102+ if ( ! fs . existsSync ( instance . absoluteCwdPath ( ) ) ) return instance . failure ( new StartupDockerProcessError ( "工作目录并不存在" ) ) ;
106103
107104 try {
108105 // 锁死实例
@@ -145,23 +142,25 @@ export default class DockerStartCommand extends InstanceCommand {
145142 // 解析额外路径挂载
146143 const extraVolumes = instance . config . docker . extraVolumes ;
147144 const extraBinds = [ ] ;
148- for ( let it of extraVolumes ) {
149- if ( ! it ) continue ;
150- const element = it . split ( ":" ) ;
151- if ( element . length != 2 ) continue ;
152- let [ hostPath , containerPath ] = element ;
145+ if ( extraVolumes ) {
146+ for ( let it of extraVolumes ) {
147+ if ( ! it ) continue ;
148+ const element = it . split ( ":" ) ;
149+ if ( element . length != 2 ) continue ;
150+ let [ hostPath , containerPath ] = element ;
153151
154- if ( path . isAbsolute ( containerPath ) ) {
155- containerPath = path . normalize ( containerPath ) ;
156- } else {
157- containerPath = path . normalize ( path . join ( "/workspace/" , containerPath ) ) ;
158- }
159- if ( path . isAbsolute ( hostPath ) ) {
160- hostPath = path . normalize ( hostPath ) ;
161- } else {
162- hostPath = path . normalize ( path . join ( process . cwd ( ) , hostPath ) ) ;
152+ if ( path . isAbsolute ( containerPath ) ) {
153+ containerPath = path . normalize ( containerPath ) ;
154+ } else {
155+ containerPath = path . normalize ( path . join ( "/workspace/" , containerPath ) ) ;
156+ }
157+ if ( path . isAbsolute ( hostPath ) ) {
158+ hostPath = path . normalize ( hostPath ) ;
159+ } else {
160+ hostPath = path . normalize ( path . join ( process . cwd ( ) , hostPath ) ) ;
161+ }
162+ extraBinds . push ( `${ hostPath } :${ containerPath } ` ) ;
163163 }
164- extraBinds . push ( `${ hostPath } :${ containerPath } ` ) ;
165164 }
166165
167166 // 内存限制
@@ -202,8 +201,7 @@ export default class DockerStartCommand extends InstanceCommand {
202201 logger . info ( `工作目录: ${ cwd } ` ) ;
203202 logger . info ( `网络模式: ${ instance . config . docker . networkMode } ` ) ;
204203 logger . info ( `端口映射: ${ JSON . stringify ( publicPortArray ) } ` ) ;
205- if ( extraBinds . length > 0 )
206- logger . info ( `额外挂载: ${ JSON . stringify ( extraBinds ) } ` ) ;
204+ if ( extraBinds . length > 0 ) logger . info ( `额外挂载: ${ JSON . stringify ( extraBinds ) } ` ) ;
207205 logger . info ( `网络别名: ${ JSON . stringify ( instance . config . docker . networkAliases ) } ` ) ;
208206 if ( maxMemory ) logger . info ( `内存限制: ${ maxMemory } MB` ) ;
209207 logger . info ( `类型: Docker 容器` ) ;
@@ -237,7 +235,7 @@ export default class DockerStartCommand extends InstanceCommand {
237235 NetworkingConfig : {
238236 EndpointsConfig : {
239237 [ instance . config . docker . networkMode ] : {
240- " Aliases" : instance . config . docker . networkAliases
238+ Aliases : instance . config . docker . networkAliases
241239 }
242240 }
243241 }
0 commit comments