Skip to content

Commit 65aceed

Browse files
committed
dig further into the runc hole
1 parent 29eb85c commit 65aceed

File tree

4 files changed

+37
-33
lines changed

4 files changed

+37
-33
lines changed

README.md

+32-28
Original file line numberDiff line numberDiff line change
@@ -44,37 +44,10 @@ electron.crashReporter.start({
4444
})
4545
```
4646

47-
### Unit file
48-
```service
49-
[Unit]
50-
Description=Container myalpine
51-
52-
[Service]
53-
Environment=NODE_ENV=production
54-
Environment=PORT=8081
55-
Environment=CRASH_REPORTS_PATH=/root/reports
56-
ExecStart=/usr/bin/systemd-nspawn \
57-
--quiet \
58-
--keep-unit \
59-
--boot \
60-
--link-journal=try-guest \
61-
--directory=/var/lib/container/electron-crash-reporter-service \
62-
--network-macvlan=eth0 \
63-
/usr/bin/env node \
64-
/usr/root/electron-crash-reporter-service/index.js
65-
KillMode=mixed
66-
Type=notify
67-
RestartForceExitStatus=133
68-
SuccessExitStatus=133
69-
70-
[Install]
71-
WantedBy=multi-user.target
72-
```
73-
7447
## Environment variables
7548
```sh
7649
PORT [80] # Set the port the service should listen to
77-
CRASH_REPORTS_PATH [/var/crash-reports] # Location to store crash reports
50+
STORAGE_PATH [/var/crash-reports] # Location to store crash reports
7851
NODE_ENV [production] # production|development
7952
```
8053

@@ -87,6 +60,37 @@ NODE_ENV [production] # production|development
8760
## Peer Dependencies
8861
None
8962

63+
## Unit file
64+
Save the unit file as `/etc/systemd/system/electron-crash-reporter.service`,
65+
and the application image as `/images/electron-crash-report-service.aci`
66+
67+
```unit
68+
[Unit]
69+
Description=electron-crash-report-service
70+
Requires=network-online.target
71+
After=network-online.target
72+
73+
[Service]
74+
Slice=machine.slice
75+
Delegate=true
76+
CPUQuota=10%
77+
MemoryLimit=1G
78+
Environment=PORT=80
79+
Environment=STORAGE_PATH=/var/crash-reports
80+
Environment=NODE_ENV=production
81+
ExecStart=/usr/bin/rkt run --inherit-env /images/electron-crash-report-service.aci
82+
ExecStopPost=/usr/bin/rkt gc --mark-only
83+
KillMode=mixed
84+
Restart=always
85+
```
86+
87+
You can then run it using `systemctl`:
88+
```sh
89+
$ sudo systemctl start etcd.service
90+
$ sudo systemctl stop etcd.service
91+
$ sudo systemctl restart etcd.service
92+
```
93+
9094
## See Also
9195
- [electron/api/crash-reporters](https://github.com/electron/electron/blob/master/docs/api/crash-reporter.md)
9296
- [feross/webtorrent.io](https://github.com/feross/webtorrent.io/blob/master/server/desktop-api.js)

build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ acbuild --debug run -- npm install --quiet --production --prefix=/var/www
3939
acbuild --debug port add http tcp 80
4040
acbuild --debug environment add PORT 80
4141
acbuild --debug environment add NODE_ENV 'production'
42-
acbuild --debug environment add CRASH_REPORTS_PATH '/var/crash-reports'
42+
acbuild --debug environment add STORAGE_PATH '/var/crash-reports'
4343

4444
# Finalize
4545
acbuild --debug write --overwrite "${OUTDIR}/${NAME}.aci"

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var pino = require('pino')
88
var fs = require('fs')
99

1010
var config = {
11-
CRASH_REPORTS_PATH: String,
11+
STORAGE_PATH: String,
1212
NODE_ENV: String,
1313
PORT: String
1414
}
@@ -46,13 +46,13 @@ var errors = {
4646
}
4747
}
4848

49-
mkdirp.sync(env.CRASH_REPORTS_PATH)
49+
mkdirp.sync(env.STORAGE_PATH)
5050

5151
router.route('GET', '/404', function (req, res, ctx) {
5252
return res.end(errors.ENOTFOUND(req, res))
5353
})
5454

55-
var upload = multer({ DEST: env.CRASH_REPORTS_PATH }).single('upload_file_minidumps')
55+
var upload = multer({ DEST: env.STORAGE_PATH }).single('upload_file_minidumps')
5656
router.route('POST', '/crash-report', function (req, res, ctx) {
5757
upload(req, res, function (err) {
5858
if (err) return res.end(errors.EREPORTPARSE(req, res, err))

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "MIT",
77
"scripts": {
88
"deps": "dependency-check . && dependency-check . --extra --no-dev",
9-
"start": "CRASH_REPORTS_PATH=/tmp/crash-reports NODE_ENV=development PORT=8080 nodemon . | pino-colada",
9+
"start": "STORAGE_PATH=/tmp/crash-reports NODE_ENV=development PORT=8080 nodemon . | pino-colada",
1010
"test": "standard && npm run deps",
1111
"coverage": "nyc report --reporter=text-lcov > coverage.lcov"
1212
},

0 commit comments

Comments
 (0)