Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fabo/51 small fixes #67

Merged
merged 5 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ $ npm run pack
$ npm run test
```

## Debug

To debug the electron application first build it and then run the node inspector for the build files:

```bash
$ electron --inspect-brk builds/{{you build}}/resources/app/dist/main.js
Copy link
Collaborator

@jbibla jbibla Nov 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*your build

```

Then attach to the debugger via the posted url in Chrome.


To debug the electron view, set the environment variable `COSMOS_DEVTOOLS` to sth. truthy like `"true"`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe sth --> something (readme can be verbose)


To see the console output of the view in your terminal, set the environment variable `ELECTRON_ENABLE_LOGGING` to sth. truthy like `1`.


## FAQ

Expand All @@ -93,4 +108,13 @@ $ npm run rebuild
- If electron shows the error: "A DLL initialization routine has failed." rebuild the electron dependencies.
```bash
$ npm run rebuild
```

- If you have trouble installing dependencies, remove all the lockfiles and try again.

```bash
$ rm -rf app/yarn.lock
$ rm -rf app/package-lock.json
$ rm -rf yarn.lock
$ rm -rf package-lock.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny and sad that we have to say to this... Maybe we should put it in a npm run rm-lockfiles script?

```
28 changes: 13 additions & 15 deletions app/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ let rmdir = require('../helpers/rmdir.js')

let shuttingDown = false
let mainWindow
let basecoinProcess, baseserverProcess, tendermintProcess
let baseserverProcess
let streams = []
let nodeIP
const WIN = /^win/.test(process.platform)
const DEV = process.env.NODE_ENV === 'development'
const TEST = JSON.parse(process.env.COSMOS_TEST || 'false') !== false
// TODO default logging or default disable logging?
Expand All @@ -28,8 +29,9 @@ const winURL = DEV
// this network gets used if none is specified via the
// COSMOS_NETWORK env var
let DEFAULT_NETWORK = join(__dirname, '../networks/tak')
let networkPath = process.env.COSMOS_NETWORK || DEFAULT_NETWORK

let SERVER_BINARY = 'baseserver'
let SERVER_BINARY = 'baseserver' + (WIN ? '.exe' : '')

function log (...args) {
if (LOGGING) {
Expand Down Expand Up @@ -76,21 +78,11 @@ function shutdown () {
mainWindow = null
shuttingDown = true

if (basecoinProcess) {
log('killing basecoin')
basecoinProcess.kill('SIGKILL')
basecoinProcess = null
}
if (baseserverProcess) {
log('killing baseserver')
baseserverProcess.kill('SIGKILL')
baseserverProcess = null
}
if (tendermintProcess) {
log('killing tendermint')
tendermintProcess.kill('SIGKILL')
tendermintProcess = null
}

return Promise.all(
streams.map(stream => new Promise((resolve) => stream.close(resolve)))
Expand Down Expand Up @@ -169,7 +161,13 @@ function startProcess (name, args, env) {

let argString = args.map((arg) => JSON.stringify(arg)).join(' ')
log(`spawning ${binPath} with args "${argString}"`)
let child = spawn(binPath, args, env)
let child
try {
child = spawn(binPath, args, env)
} catch (err) {
log(`Err: Spawning ${name} failed`, err)
throw err
}
child.stdout.on('data', (data) => !shuttingDown && log(`${name}: ${data}`))
child.stderr.on('data', (data) => !shuttingDown && log(`${name}: ${data}`))
child.on('exit', (code) => !shuttingDown && log(`${name} exited with code ${code}`))
Expand Down Expand Up @@ -233,6 +231,7 @@ function exists (path) {
}

async function initBaseserver (chainId, home, node) {
// fs.ensureDirSync(home)
// `baseserver init` to generate config, trust seed
let child = startProcess(SERVER_BINARY, [
'init',
Expand Down Expand Up @@ -349,7 +348,7 @@ async function main () {
let genesisJSON = JSON.parse(existingGenesis)
// skip this check for local testnet
if (genesisJSON.chain_id !== 'local') {
let specifiedGenesis = fs.readFileSync(join(process.env.COSMOS_NETWORK, 'genesis.json'), 'utf8')
let specifiedGenesis = fs.readFileSync(join(networkPath, 'genesis.json'), 'utf8')
if (existingGenesis.trim() !== specifiedGenesis.trim()) {
log('genesis has changed')
await backupData(root)
Expand All @@ -364,7 +363,6 @@ async function main () {
await fs.ensureDir(root)

// copy predefined genesis.json and config.toml into root
let networkPath = process.env.COSMOS_NETWORK || DEFAULT_NETWORK
fs.accessSync(networkPath) // crash if invalid path
fs.copySync(networkPath, root)

Expand Down
5 changes: 4 additions & 1 deletion tasks/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ function goBuild (pkg) {

mkdirp(path.join(buildPath, 'bin'))
let binPath = path.join(buildPath, 'bin', name)
let cmd = `GOOS=${platform} GOARCH=${arch} go build -o ${binPath} ${pkg}`
if (platform === 'windows') {
binPath = binPath + '.exe'
}
let cmd = `cross-env GOOS=${platform} GOARCH=${arch} go build -o ${binPath} ${pkg}`
console.log(`> ${cmd}\n`)
let go = exec(cmd)

Expand Down