-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSakefile.ts
98 lines (81 loc) · 2.72 KB
/
Sakefile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use('sake-bundle')
use('sake-outdated')
use('sake-version')
var os = require('os')
var fs = require('fs')
var tar = require('tar')
var extensionConversion = {
win32: '.zip',
linux: '.tar.gz',
darwin: '.tar.gz',
}
var platformConversion = {
win32: 'windows-386',
linux: 'linux-386',
darwin: 'darwin-amd64',
}
var gethUriPrefix = 'https://gethstore.blob.core.windows.net/builds/'
var gethFilePrefix = 'geth-'
var gethVersion = '1.7.2-1db4ecdc'
function downloadGeth(platform: string) {
exec('mkdir .geth')
var ext = extensionConversion[platform]
var file = gethFilePrefix
+ platformConversion[platform]
+ '-'
+ gethVersion
+ ext
var uri = gethUriPrefix + file
console.log('Downloading "' + uri + '"')
exec.sync(`curl -O "${ uri }"`)
return file
}
task('start', function* (opts) {
console.log(`Starting Geth-Node
INSTANCE: ${ process.env.GAE_INSTANCE }
GAE_MEMORY_MB: ${ process.env.GAE_MEMORY_MB }
GAE_SERVICE: ${ process.env.GAE_SERVICE }
GAE_VERSION: ${ process.env.GAE_VERSION }
GCLOUD_PROJECT: ${ process.env.GCLOUD_PROJECT }
NODE_ENV: ${ process.env.NODE_ENV }
PORT: ${ process.env.PORT }
`)
var platform = os.platform()
var testnet = (process.env.GAE_SERVICE == 'geth-node-testnet' ? '--testnet' : '')
console.log(`Downloading Geth for ${ platform }`)
switch(platform) {
case 'win32':
console.log('Windows is not currently supported')
return
default:
try {
fs.statSync('.geth/geth')
} catch (e) {
var file = downloadGeth(platform)
console.log('Decompressing Geth')
tar.x({
file: file,
sync: true,
cwd: '.geth',
})
exec.sync('mv .geth/' + file.split('.tar')[0] + '/geth .geth')
}
}
console.log('Starting Geth')
status = (yield exec.interactive(`.geth/geth ${ testnet } --fast --cache=96 --datadir .ethereum --rpcport ${ process.env.PORT || 8080 }`)).status
})
task('auth', 'authenticate google sdk', (opts) => {
exec('gcloud auth login')
})
task('deploy:testnet', 'deploy reader to appengine', (opts) => {
exec('gcloud app deploy --quiet --project crowdstart-us app.testnet.yaml --version=v1')
})
task('deploy:ethereum', 'deploy reader to appengine', (opts) => {
exec('gcloud app deploy --quiet --project crowdstart-us app.ethereum.yaml --version=v1')
})
task('browse', 'view application from web browser', (opts) => {
exec('gcloud app browse -s geth-node-ethereum --project crowdstart-us app.ethereum.yaml')
})
task('logs', 'view application logs', (opts) => {
exec('gcloud app logs tail -s geth-node-ethereum --project crowdstart-us')
})