Bläddra i källkod

fixes for start and stop

production
guest 2 år sedan
förälder
incheckning
f5d0e7d83b
3 ändrade filer med 94 tillägg och 49 borttagningar
  1. 90
    49
      index.js
  2. 2
    0
      lin_verse.js
  3. 2
    0
      win_verse.js

+ 90
- 49
index.js Visa fil

function startFn( o ){ function startFn( o ){
var cmd = [nodecmd, [`--inspect=${o.debugport}`, '--preserve-symlinks', o.script]] var cmd = [nodecmd, [`--inspect=${o.debugport}`, '--preserve-symlinks', o.script]]
console.log(`Starting ${o.name}.`); 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 child = childPromise.process;
var cpid = child.pid 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') { if(clioverrides.node_env === 'development') {
env.DEBUG = 'loopback:connector:' + dbForLabel(label) 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'() // cmd = 'node'()


// cwd : 'client/', // cwd : 'client/',
// env: env // 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) => { , 'stop': (label) => {
const kill = require('tree-kill'); 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' : () => { , 'model' : () => {
var etask = ()=>{ var etask = ()=>{

+ 2
- 0
lin_verse.js Visa fil

// this with sudo and change all calles to use ony where required. // this with sudo and change all calles to use ony where required.
return elevatedRunner(taskToRun); return elevatedRunner(taskToRun);
} }
, iswin(){ return false}
, islin(){ return true}
} }


module.exports = shell_verse module.exports = shell_verse

+ 2
- 0
win_verse.js Visa fil

.catch(err => console.error('Elevation failed : ' + err)); .catch(err => console.error('Elevation failed : ' + err));
}) })
} }
, iswin(){ return true}
, islin(){ return false}
} }


module.exports = shell_verse module.exports = shell_verse

Laddar…
Avbryt
Spara