Skip to content

Commit 9e3b436

Browse files
committed
chore: package as deb and enable reading ENV vars
1 parent 76741ba commit 9e3b436

6 files changed

Lines changed: 67 additions & 5 deletions

File tree

.github/workflows/publish_deb.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish deb
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
docker-release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-node@v3
13+
with:
14+
node-version: 18
15+
- name: Build deb package
16+
if: success()
17+
run: |
18+
npm ci
19+
npm run build
20+
npx node-deb -- dist/
21+
- name: Upload deb package
22+
if: success()
23+
uses: alexellis/upload-assets@0.3.0
24+
env:
25+
GITHUB_TOKEN: ${{ github.token }}
26+
with:
27+
asset_paths: '["etherproxy_*deb"]'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
.DS_Store
33
dist
4+
*.deb

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "etherproxy",
33
"version": "1.3.0",
4-
"description": "",
4+
"description": "JSON-RPC reverse proxy tool designed for caching requests",
55
"main": "dist/index.js",
66
"bin": {
77
"etherproxy": "./dist/index.js"
@@ -12,7 +12,7 @@
1212
"build": "tsc"
1313
},
1414
"keywords": [],
15-
"author": "",
15+
"author": "@Cafe137",
1616
"license": "MIT",
1717
"dependencies": {
1818
"cafe-utility": "^10.8.1",
@@ -22,5 +22,17 @@
2222
"@types/node": "^18.15.11",
2323
"@types/node-fetch": "^2.6.3",
2424
"typescript": "^5.0.3"
25+
},
26+
"node_deb": {
27+
"entrypoints": {
28+
"daemon": "dist/index.js"
29+
},
30+
"init": "systemd",
31+
"install_strategy": "copy",
32+
"package_name": "etherproxy",
33+
"templates": {
34+
"default_variables": "packaging/default/etherproxy",
35+
"systemd_service": "packaging/systemd/etherproxy.service"
36+
}
2537
}
2638
}

packaging/default/etherproxy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Configuration for etherproxy daemon
2+
3+
#ETHERPROXY_TARGET=http://localhost:8545
4+
#ETHERPROXY_PORT=9000
5+
#ETHERPROXY_EXPIRY=2000
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Unit]
2+
Description=JSON-RPC reverse proxy tool designed for caching requests
3+
Requires=network.target
4+
5+
[Service]
6+
Type=simple
7+
EnvironmentFile=/etc/default/etherproxy
8+
WorkingDirectory=/usr/share/etherproxy/app
9+
ExecStart=/usr/share/etherproxy/app/dist/index.js
10+
ExecReload=/bin/kill -HUP $MAINPID
11+
Restart=always
12+
User=etherproxy
13+
PermissionsStartOnly=true
14+
SyslogIdentifier=etherproxy
15+
16+
[Install]
17+
WantedBy=multi-user.target

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { fetchWithTimeout, respondWithFetchPromise } from './utility'
99
main()
1010

1111
function main() {
12-
const port = Arrays.requireNumberArgument(process.argv, 'port')
13-
const target = Arrays.requireStringArgument(process.argv, 'target')
14-
const expiry = Arrays.requireNumberArgument(process.argv, 'expiry')
12+
const port: number = parseInt(Arrays.getArgument(process.argv, 'port') as string) || parseInt((process.env.ETHERPROXY_PORT as string)) || 9000
13+
const target: string = Arrays.getArgument(process.argv, 'target') as string || process.env.ETHERPROXY_TARGET as string || "http://localhost:8545"
14+
const expiry: number = parseInt(Arrays.getArgument(process.argv, 'expiry') as string) || parseInt((process.env.ETHERPROXY_EXPIRY as string)) || 2000
1515

1616
const fastIndex = Objects.createFastIndex()
1717
const server = createServer(async (request: IncomingMessage, response: ServerResponse) => {

0 commit comments

Comments
 (0)