-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60a0d1f
commit 857d889
Showing
13 changed files
with
229 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ deploy.log | |
|
||
# Next.js | ||
.next | ||
.next-* | ||
|
||
# builds | ||
dist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Explored } from '@siafoundation/explored-js' | ||
import { Hostd } from '@siafoundation/hostd-js' | ||
import { Bus } from '@siafoundation/renterd-js' | ||
import { startWebServerCluster, stopWebServer } from './webServerCluster' | ||
import { | ||
clusterd, | ||
renterdWaitForContracts, | ||
setupCluster, | ||
teardownCluster, | ||
} from '@siafoundation/clusterd' | ||
|
||
export async function startCluster() { | ||
const exploredCount = 1 | ||
const renterdCount = 1 | ||
const hostdCount = 3 | ||
await setupCluster({ | ||
exploredCount, | ||
renterdCount, | ||
hostdCount, | ||
}) | ||
const renterd = clusterd.nodes.find((n) => n.type === 'renterd') | ||
const explored = clusterd.nodes.find((n) => n.type === 'explored') | ||
const hostds = clusterd.nodes.filter((n) => n.type === 'hostd') | ||
await renterdWaitForContracts({ renterdNode: renterd, hostdCount }) | ||
const daemons = { | ||
renterd, | ||
explored, | ||
hostds, | ||
} | ||
const apis = { | ||
renterd: Bus({ | ||
api: `${renterd.apiAddress}/api`, | ||
password: renterd.password, | ||
}), | ||
explored: Explored({ | ||
api: `${explored.apiAddress}/api`, | ||
password: explored.password, | ||
}), | ||
hostds: hostds.map((h) => | ||
Hostd({ | ||
api: `${h.apiAddress}/api`, | ||
password: h.password, | ||
}) | ||
), | ||
} | ||
const { baseUrl } = await startWebServerCluster({ | ||
exploredAddress: daemons.explored.apiAddress, | ||
}) | ||
console.log(` | ||
webServerUrl: ${baseUrl} | ||
clusterd: http://localhost:${clusterd.managementPort} | ||
explored: ${daemons.explored.apiAddress} | ||
renterd: ${daemons.renterd.apiAddress} | ||
hostds: ${daemons.hostds.map((h) => h.apiAddress)} | ||
`) | ||
return { | ||
webServerUrl: baseUrl, | ||
clusterd, | ||
apis, | ||
daemons, | ||
} | ||
} | ||
|
||
export async function stopCluster() { | ||
stopWebServer() | ||
teardownCluster() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { ChildProcess, spawn } from 'child_process' | ||
import { workspaceRoot } from '@nx/devkit' | ||
import net from 'net' | ||
|
||
let server: ChildProcess | ||
let baseUrl: string | ||
|
||
// Starts the explorer app webserver configured to run against the testnet | ||
// cluster provided via the NEXT_PUBLIC_EXPLORED_ADDRESS environment variable. | ||
export async function startWebServerCluster({ | ||
exploredAddress, | ||
}: { | ||
exploredAddress: string | ||
}) { | ||
const port = await findFreePort() | ||
server = spawn( | ||
'npx', | ||
[ | ||
'nx', | ||
'run', | ||
'explorer:serve:development-testnet-cluster', | ||
'--port', | ||
port.toString(), | ||
], | ||
{ | ||
cwd: workspaceRoot, | ||
shell: true, | ||
env: { | ||
...process.env, | ||
NEXT_PUBLIC_EXPLORED_ADDRESS: exploredAddress, | ||
}, | ||
} | ||
) | ||
|
||
server.stdout.on('data', (data) => { | ||
console.log(data.toString()) | ||
}) | ||
|
||
server.stderr.on('data', (data) => { | ||
console.error(data.toString()) | ||
}) | ||
|
||
// Wait until stdout prints "Ready", eg: | ||
// ✓ Starting... | ||
// ✓ Ready in 1606ms | ||
await new Promise((resolve) => { | ||
server.stdout.on('data', (data) => { | ||
if (data.toString().includes('Ready')) { | ||
console.log('Server ready') | ||
resolve(true) | ||
} | ||
}) | ||
}) | ||
baseUrl = `http://localhost:${port}` | ||
return { | ||
baseUrl, | ||
} | ||
} | ||
|
||
export function stopWebServer() { | ||
console.log('Stopping webserver: ', baseUrl) | ||
server.kill() // Kill the server after each test | ||
} | ||
|
||
async function findFreePort(): Promise<number> { | ||
return new Promise((res) => { | ||
const srv = net.createServer() | ||
srv.listen(0, () => { | ||
const addr = srv.address() | ||
if (typeof addr === 'string') { | ||
throw new Error('Address is a string') | ||
} | ||
const port = addr.port | ||
srv.close(() => res(port)) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { webLinks } from '@siafoundation/design-system' | ||
|
||
export const network = 'zen' | ||
export const networkName = 'Zen Testnet' | ||
export const siteName = 'zen.siascan.com' | ||
export const appName = 'siascan' | ||
export const appLink = webLinks.explore.testnetZen | ||
export const isMainnet = false | ||
|
||
// APIs | ||
export const faucetApi = 'https://api.siascan.com/zen/faucet' | ||
export const siaCentralApi = 'https://api.siacentral.com/v2/zen' | ||
export const exploredApi = `${process.env.NEXT_PUBLIC_EXPLORED_ADDRESS}/api` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.