瀏覽代碼

fixes for start and stop

pull/9/head
guest 2 年之前
父節點
當前提交
f5d0e7d83b
共有 3 個文件被更改,包括 94 次插入49 次删除
  1. 90
    49
      index.js
  2. 2
    0
      lin_verse.js
  3. 2
    0
      win_verse.js

+ 90
- 49
index.js 查看文件

@@ -1874,31 +1874,56 @@ var op = {
function startFn( o ){
var cmd = [nodecmd, [`--inspect=${o.debugport}`, '--preserve-symlinks', o.script]]
console.log(`Starting ${o.name}.`);
var childPromise = nodeShellExec('cmd', ['/k', getCmdString(cmd) ], {
// inherit : true,
shell: true,
detached: true,
stdio: 'ignore',
cwd: instanceroot + o.path
, env: env
})

if(shell_verse.iswin()){
var __cmd = 'cmd'
var a1 = '/k'
}
else if(shell_verse.islin()) {
var __cmd = 'sh'
var a1 = '-c'
}

if(o.cmd) {
cmd = o.cmd
var childPromise = nodeShellExec(...o.cmd, {
// inherit : true,
shell: true,
detached: true,
stdio: 'ignore',
cwd: instanceroot + o.path
, env: env
})
}
else {
var childPromise = nodeShellExec(__cmd, [a1, getCmdString(cmd) ], {
// inherit : true,
shell: true,
detached: true,
stdio: 'ignore',
cwd: instanceroot + o.path
, env: env
})
}

var child = childPromise.process;
var cpid = child.pid
if (typeof child.pid !== 'undefined') {
childPromise.then(()=>{
console.log(` *** started Elixir Loopback Server PID(${cpid}) : NODE_ENV=${clioverrides.node_env} ${cmd}`);
fs.writeFileSync('.elixir-server.elixir.server.pid', '' + cpid)
childPromise.then(()=>{
console.log(` *** started ${o.name} PID(${cpid}) ${cmd}`);
fs.writeFileSync(o.pidstore, '' + cpid)
})
.catch(e => console.errror(e) )
}
.catch(e => console.error(e) )
}

if(clioverrides.node_env === 'development') {
env.DEBUG = 'loopback:connector:' + dbForLabel(label)
startFn( { debugport : 9228, script : 'elixir/server.js', name : 'Elixir Loopback Server', path : '/' + 'elixir-server' } )
startFn( { debugport : 9227, script : 'bin/www', name : 'Express Server', path : '/' + 'chess-server-lib/server' } )
startFn( { debugport : 9228, script : 'elixir/server.js', name : 'Elixir Loopback Server', path : '/' + 'elixir-server'
, pidstore : '.express.server.pid'
} )
startFn( { debugport : 9227, script : 'bin/www', name : 'Express Server', path : '/' + 'chess-server-lib/server'
, pidstore : '.elixir-server.elixir.server.pid'
} )
// cmd = 'node'()

@@ -1916,46 +1941,62 @@ var op = {
// cwd : 'client/',
// env: env
// })
console.log('Starting Elixir Client Host.');
var cmd = ['ember', ['s']]
var childPromise = nodeShellExec(...cmd, {
// var childPromise = nodeShellExec('node', ['--inspect=9227', './node_modules/.bin/ember', 's'], {
// PB : TODO -- ember debugging.
// inherit : true,
shell: true,
detached: true,
stdio: 'ignore',
cwd: instanceroot + '/' + 'client'
, env: env
})
// .catch(e=>console.error(e))
startFn( {
name : 'Elixir Ember Client', path : '/' + 'client'
, cmd : ['node_modules/ember-cli/bin/ember', ['s']]
, pidstore : '.client.server.pid'
} )

child = childPromise.process;
if (typeof child.pid !== 'undefined') {
console.log(`started Elixir Client Host PID(${child.pid}) : NODE_ENV=${process.NODE_ENV} ${cmd}`);
fs.writeFileSync('.client.server.pid', child.pid, {
encoding: 'utf8'
})
}
// console.log('Starting Elixir Ember Client');
// var cmd = ['ember', ['s']]
// var childPromise = nodeShellExec(...cmd, {
// // var childPromise = nodeShellExec('node', ['--inspect=9227', './node_modules/.bin/ember', 's'], {
// // PB : TODO -- ember debugging.
// // inherit : true,
// shell: true,
// detached: true,
// stdio: 'ignore',
// cwd: instanceroot + '/' + 'client'
// , env: env
// })
// // .catch(e=>console.error(e))

// child = childPromise.process;
// if (typeof child.pid !== 'undefined') {
// console.log(`started Elixir Client Host PID(${child.pid}) : NODE_ENV=${process.NODE_ENV} ${cmd}`);
// fs.writeFileSync('.client.server.pid', '' + child.pid, {
// encoding: 'utf8'
// })
// }
}

}
, 'stop': (label) => {
const kill = require('tree-kill');

var serverPid = fs.readFileSync('.elixir-server.elixir.server.pid', {
encoding: 'utf8'
})
fs.unlinkSync('.elixir-server.elixir.server.pid')
console.log(serverPid)
kill(serverPid)
try{
var serverPid = fs.readFileSync('.elixir-server.elixir.server.pid', { encoding: 'utf8'})
fs.unlinkSync('.elixir-server.elixir.server.pid')
console.log(serverPid)
kill(serverPid)
}
catch(e){ console.error(e) }

serverPid = fs.readFileSync('.express.server.pid', {
encoding: 'utf8'
})
fs.unlinkSync('.express.server.pid')
console.log(serverPid)
kill(serverPid)
try{
serverPid = fs.readFileSync('.express.server.pid', { encoding: 'utf8' })
fs.unlinkSync('.express.server.pid')
console.log(serverPid)
kill(serverPid)
}
catch(e){ console.error(e) }

try{
serverPid = fs.readFileSync('.client.server.pid', { encoding: 'utf8' })
fs.unlinkSync('.client.server.pid')
console.log(serverPid)
kill(serverPid)
}
catch(e){ console.error(e) }
}
, 'model' : () => {
var etask = ()=>{

+ 2
- 0
lin_verse.js 查看文件

@@ -163,6 +163,8 @@ var shell_verse = {
// this with sudo and change all calles to use ony where required.
return elevatedRunner(taskToRun);
}
, iswin(){ return false}
, islin(){ return true}
}

module.exports = shell_verse

+ 2
- 0
win_verse.js 查看文件

@@ -208,6 +208,8 @@ var shell_verse = {
.catch(err => console.error('Elevation failed : ' + err));
})
}
, iswin(){ return true}
, islin(){ return false}
}

module.exports = shell_verse

Loading…
取消
儲存