Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Merge pull request #523 from NebulousLabs/loadingscreen-info
Browse files Browse the repository at this point in the history
display siad's stderr on loadingscreen if load fails
  • Loading branch information
lukechampine committed Mar 15, 2017
2 parents f618164 + 67f7a7e commit 31262f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion css/general.css
Expand Up @@ -274,7 +274,7 @@ html,body {
height: 100%;

text-align: center;
font-size: 50px;
font-size: 35px;
background-color: #fff;
opacity: .5;
}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -14,7 +14,7 @@
<div class='overlay'>
<div class='centered'>
<p id="overlay-text"></p>
<i class='fa fa-spinner fa-pulse'></i>
<i id="loading-spinner" class='fa fa-spinner fa-pulse'></i>
</div>
</div>
<!-- Header for UI -->
Expand Down
17 changes: 15 additions & 2 deletions js/rendererjs/loadingScreen.js
Expand Up @@ -14,12 +14,14 @@ const fs = remote.require('fs')
const config = remote.getGlobal('config')
const siadConfig = config.attr('siad')

const spinner = document.getElementById('loading-spinner')
const overlay = document.getElementsByClassName('overlay')[0]
const overlayText = overlay.getElementsByClassName('centered')[0].getElementsByTagName('p')[0]
overlayText.textContent = 'Loading Sia...'

const showError = (error) => {
overlayText.textContent = 'A Sia-UI error has occured: ' + error
spinner.style.display = 'none'
}

// startUI starts a Sia UI instance using the given welcome message.
Expand Down Expand Up @@ -56,6 +58,17 @@ const checkSiaPath = () => new Promise((resolve) => {
})
})

// unexpectedExitHandler handles an unexpected siad exit, displaying the error
// piped to siad-output.log.
const unexpectedExitHandler = () => {
try {
const errorMsg = fs.readFileSync(Path.join(siadConfig.datadir, 'siad-output.log'))
showError('Siad unexpectedly exited. Error log: ' + errorMsg)
} catch (e) {
showError('Siad unexpectedly exited.')
}
}

// Check if Siad is already running on this host.
// If it is, start the UI and display a welcome message to the user.
// Otherwise, start a new instance of Siad using config.js.
Expand Down Expand Up @@ -99,8 +112,8 @@ export default async function loadingScreen(initUI) {
'api-addr': siadConfig.address,
})
siadProcess.on('error', (e) => showError('Siad couldnt start: ' + e.toString()))
siadProcess.on('close', () => showError('Siad unexpectedly closed.'))
siadProcess.on('exit', () => showError('Siad unexpectedly exited.'))
siadProcess.on('close', unexpectedExitHandler)
siadProcess.on('exit', unexpectedExitHandler)
window.siadProcess = siadProcess
} catch (e) {
showError(e.toString())
Expand Down

0 comments on commit 31262f7

Please sign in to comment.