Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit 2427b3c

Browse files
authored
remove storage (the great simplification) (#134)
* remove storage (the great simplification) * fix docker ci * `--help` * ci * docs * remove double log * fix missing .source through types * safeguard #emit * typecheck metrics#submit * types * more types :) * fix merge metrics logic * refactor using `onActivity` * refactor using `onMetrics` * add passing test for merging metrics * add passing test for metrics deduplication * docs
1 parent 9285829 commit 2427b3c

25 files changed

+242
-1427
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ jobs:
8989
- name: Print station activity
9090
run: |
9191
sleep 10 # Wait for Station modules to start
92-
docker exec station bin/station.js activity
92+
docker logs station
9393
9494
- name: Check | Saturn started
95-
run: docker exec station bin/station.js activity | grep "Saturn module started"
95+
run: docker logs station | grep "Saturn module started"
9696

9797
- name: Check | Zinnia started
98-
run: docker exec station bin/station.js activity | grep "Zinnia started"
98+
run: docker logs station | grep "Zinnia started"

README.md

Lines changed: 3 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -122,127 +122,13 @@ Modules currently in experimental mode:
122122

123123
- [Bacalhau](https://github.com/bacalhau-project/bacalhau)
124124

125-
### `$ station metrics <module>`
126-
127-
Get combined metrics from all Station Modules:
128-
129-
```bash
130-
$ station metrics
131-
{
132-
"totalJobsCompleted": 123,
133-
"totalEarnings": "0"
134-
}
135-
```
136-
137-
Get metrics from a specific Station Module:
138-
139-
```bash
140-
$ station metrics saturn-l2-node
141-
{
142-
"totalJobsCompleted": 123,
143-
"totalEarnings": "0"
144-
}
145-
```
146-
147-
Follow metrics:
148-
149-
```bash
150-
$ station metrics --follow
151-
{
152-
"totalJobsCompleted": 123,
153-
"totalEarnings": "0"
154-
}
155-
...
156-
```
157-
158-
### `$ station activity`
159-
160-
Get Station activity logs.
161-
162-
Get all activity:
163-
164-
```bash
165-
$ station activity
166-
[3/14/2023, 10:23:14 AM] INFO Saturn Node is online and connected to 1 peers
167-
[3/14/2023, 10:23:18 AM] INFO Saturn Node is online and connected to 9 peers
168-
```
169-
170-
```bash
171-
$ station activity --json
172-
[
173-
{
174-
"timestamp": "2023-04-05T11:26:41.000Z",
175-
"type": "info",
176-
"source": "Saturn",
177-
"message": "Saturn Node is online and connected to 1 peers",
178-
"id": "b6e922f2-54fb-4d5b-adcb-499391e4a09e"
179-
},
180-
{
181-
"timestamp": "2023-04-05T11:26:46.000Z",
182-
"type": "info",
183-
"source": "Saturn",
184-
"message": "Saturn Node is online and connected to 9 peers",
185-
"id": "ffb551a0-247f-471d-b4db-0145cc3b1614"
186-
}
187-
]
188-
```
189-
190-
Follow activity:
191-
192-
```bash
193-
$ station activity --follow
194-
[3/14/2023, 10:23:14 AM] INFO Saturn Node is online and connected to 1 peers
195-
[3/14/2023, 10:23:18 AM] INFO Saturn Node is online and connected to 9 peers
196-
...
197-
```
198-
199-
```bash
200-
$ station activity --follow --json
201-
{"timestamp":"2023-04-05T11:26:41.000Z","type":"info","source":"Saturn","message":"Saturn Node is online and connected to 1 peers""id":"b6e922f2-54fb-4d5b-adcb-499391e4a09e"}
202-
{"timestamp":"2023-04-05T11:26:46.000Z","type":"info","source":"Saturn","message":"Saturn Node is online and connected to 9 peers""id":"ffb551a0-247f-471d-b4db-0145cc3b1614"}
203-
```
204-
205-
### `$ station logs <module>`
206-
207-
Get combined logs from Station Core and all Station Modules:
208-
209-
```bash
210-
$ station logs
211-
[3/14/2023, 5:15:26 PM] [saturn-L2-node] INFO: Saturn Node is online and connected to 9 peers
212-
[3/14/2023, 5:15:26 PM] [saturn-L2-node] ERROR: Saturn Node is not able to connect to the network
213-
```
214-
215-
Get logs from a specific Station Module:
216-
217-
```bash
218-
$ station logs saturn-l2-node
219-
[3/14/2023, 5:15:26 PM] INFO: Saturn Node is online and connected to 9 peers
220-
[3/14/2023, 5:15:26 PM] ERROR: Saturn Node is not able to connect to the network
221-
```
222-
223-
Follow logs:
224-
225-
```bash
226-
$ station logs --follow
227-
[3/14/2023, 5:15:26 PM] [saturn-L2-node] INFO: Saturn Node is online and connected to 9 peers
228-
[3/14/2023, 5:15:26 PM] [saturn-L2-node] ERROR: Saturn Node is not able to connect to the network
229-
...
230-
```
231-
232125
### `$ station --help`
233126

234127
Show help.
235128

236129
```bash
237130
$ station --help
238-
Usage: station <command> [options]
239-
240-
Commands:
241-
station Start Station [default]
242-
station metrics [module] Show metrics
243-
station activity Show activity log
244-
station logs [module] Show module logs
245-
station events Events stream
131+
Usage: station [options]
246132

247133
Options:
248134
-j, --json Output JSON [boolean]
@@ -273,12 +159,6 @@ $ docker run \
273159
ghcr.io/filecoin-station/core
274160
```
275161

276-
Inspect logs:
277-
278-
```bash
279-
$ docker exec station ./bin/station.js logs
280-
```
281-
282162
## Manual Deployment (Ubuntu)
283163

284164
On a fresh [Ubuntu](https://ubuntu.com/) machine:
@@ -314,57 +194,9 @@ EOF
314194
$ sudo systemctl daemon-reload
315195
$ sudo systemctl start station
316196
$ sudo systemctl status station
317-
```
318-
319-
## API
320-
321-
### `Core.create({ cacheRoot?: String, stateRoot?: String }?)`
322-
323-
Returns `Promise<Core>`.
324-
325-
### `Core#logs.get(module?: String)`
326-
327-
Returns `Promise<String>`.
328197

329-
### `Core#logs.follow(module?: String)`
330-
331-
Returns `AsyncGenerator<String>`.
332-
333-
### `Core#activity.get()`
334-
335-
Returns `Promise<ActivityEvent[]>`.
336-
337-
### `Core#activity.follow({ signal?: AbortSignal, nLines = 10?: Number }?)`
338-
339-
Returns `AsyncGenerator<ActivityEvent>`.
340-
341-
### `Core#metrics.getLatest(module?: String)`
342-
343-
Returns `Promise<MetricsEvent>`.
344-
345-
### `Core#metrics.follow({ module?: String, signal?: AbortSignal }?)`
346-
347-
Returns `AsyncGenerator<MetricsEvent>`.
348-
349-
### `ActivityEvent`
350-
351-
```
352-
{
353-
timestamp: Date
354-
type: ("info"|"error")
355-
source: String
356-
message: String
357-
id: String
358-
}
359-
```
360-
361-
### `MetricsEvent`
362-
363-
```
364-
{
365-
totalJobsCompleted: Number
366-
totalEarnings: String
367-
}
198+
# Read logs
199+
$ journalctl -u station.service
368200
```
369201

370202
## Disclaimer

bin/station.js

Lines changed: 18 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
'use strict'
44

5-
const commands = require('../commands')
5+
const { station } = require('../commands/station')
66
const Sentry = require('@sentry/node')
77
const yargs = require('yargs/yargs')
88
const { hideBin } = require('yargs/helpers')
9-
// We must not require('..') as that confuses TypeScript compiler.
10-
// The compiler will look at our package.json, find that the types are in `dist/index.d.ts`
11-
// and load that output file instead of the actual input `index.js`.
12-
const { Core } = require('../index')
139
const pkg = require('../package.json')
1410

1511
Sentry.init({
@@ -20,57 +16,24 @@ Sentry.init({
2016
ignoreErrors: [/EACCES/, /EPERM/, /ENOSPC/, /EPIPE/]
2117
})
2218

23-
const main = async () => {
24-
const core = await Core.create()
25-
26-
yargs(hideBin(process.argv))
27-
.usage('Usage: $0 <command> [options]')
28-
.command(
29-
'$0',
30-
'Start Station',
31-
yargs => yargs
32-
.option('json', {
33-
alias: 'j',
34-
type: 'boolean',
35-
description: 'Output JSON'
36-
})
37-
.option('experimental', {
38-
type: 'boolean',
39-
description: 'Also run experimental modules'
40-
}),
41-
args => commands.station({ ...args, core })
42-
)
43-
.command(
44-
'metrics [module]',
45-
'Show metrics',
46-
() => {},
47-
({ follow, module }) => commands.metrics({ core, follow, module })
48-
)
49-
.command(
50-
'activity',
51-
'Show activity log',
52-
yargs => yargs.option('json', {
19+
yargs(hideBin(process.argv))
20+
.usage('Usage: $0 [options]')
21+
.command(
22+
'$0',
23+
'Start Station',
24+
yargs => yargs
25+
.option('json', {
5326
alias: 'j',
5427
type: 'boolean',
5528
description: 'Output JSON'
29+
})
30+
.option('experimental', {
31+
type: 'boolean',
32+
description: 'Also run experimental modules'
5633
}),
57-
({ follow, json }) => commands.activity({ core, follow, json })
58-
)
59-
.command(
60-
'logs [module]',
61-
'Show module logs',
62-
() => {},
63-
({ module, follow }) => commands.logs({ core, module, follow })
64-
)
65-
.choices('module', core.modules)
66-
.version(`${pkg.name}: ${pkg.version}`)
67-
.alias('v', 'version')
68-
.alias('h', 'help')
69-
.alias('f', 'follow')
70-
.parse()
71-
}
72-
73-
main().catch(err => {
74-
console.error(err)
75-
process.exit(1)
76-
})
34+
({ json, experimental }) => station({ json, experimental })
35+
)
36+
.version(`${pkg.name}: ${pkg.version}`)
37+
.alias('v', 'version')
38+
.alias('h', 'help')
39+
.parse()

commands/activity.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

commands/index.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

commands/logs.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

commands/metrics.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)