fix(app): fast and proper closing
This commit is contained in:
parent
513df76c57
commit
837f59569f
@ -162,21 +162,13 @@ const writeSphinxConfig = (path) => {
|
|||||||
|
|
||||||
const sphinxPath = path.resolve(getSphinxPath())
|
const sphinxPath = path.resolve(getSphinxPath())
|
||||||
console.log('Sphinx Path:', sphinxPath)
|
console.log('Sphinx Path:', sphinxPath)
|
||||||
let closerPath = sphinxPath.replace('searchd', 'consolekill')
|
|
||||||
if(/^win/.test(process.platform))
|
|
||||||
{
|
|
||||||
console.log('windows console closer path: ', closerPath)
|
|
||||||
console.log('cmd path', process.env.COMSPEC || 'cmd')
|
|
||||||
}
|
|
||||||
|
|
||||||
const startSphinx = (callback) => {
|
const startSphinx = (callback) => {
|
||||||
const sphinxConfigDirectory = app.getPath("userData")
|
const sphinxConfigDirectory = app.getPath("userData")
|
||||||
writeSphinxConfig(sphinxConfigDirectory)
|
writeSphinxConfig(sphinxConfigDirectory)
|
||||||
|
|
||||||
if(/^win/.test(process.platform))
|
const config = `${sphinxConfigDirectory}/sphinx.conf`
|
||||||
sphinx = spawn(process.env.COMSPEC || 'cmd', ['/c', sphinxPath, '--config', `${sphinxConfigDirectory}/sphinx.conf`])
|
sphinx = spawn(sphinxPath, ['--config', config])
|
||||||
else
|
|
||||||
sphinx = spawn(sphinxPath, ['--config', `${sphinxConfigDirectory}/sphinx.conf`])
|
|
||||||
|
|
||||||
sphinx.stdout.on('data', (data) => {
|
sphinx.stdout.on('data', (data) => {
|
||||||
console.log(`sphinx: ${data}`)
|
console.log(`sphinx: ${data}`)
|
||||||
@ -191,6 +183,10 @@ const startSphinx = (callback) => {
|
|||||||
console.log(`sphinx closed with code ${code} and signal ${signal}`)
|
console.log(`sphinx closed with code ${code} and signal ${signal}`)
|
||||||
app.quit()
|
app.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
sphinx.stop = () => {
|
||||||
|
exec(`${sphinxPath} --config "${config}" --stopwait`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tray = undefined
|
let tray = undefined
|
||||||
@ -285,17 +281,11 @@ const stop = () => {
|
|||||||
|
|
||||||
if(spider)
|
if(spider)
|
||||||
{
|
{
|
||||||
if(/^win/.test(process.platform))
|
spider.stop(() => sphinx.stop())
|
||||||
spider.stop(() => exec(`${closerPath} ${sphinx.pid}`))
|
|
||||||
else
|
|
||||||
spider.stop(() => sphinx.kill())
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(/^win/.test(process.platform))
|
sphinx.stop()
|
||||||
exec(`${closerPath} ${sphinx.pid}`)
|
|
||||||
else
|
|
||||||
sphinx.kill()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user