This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Showing
8 changed files
with
94 additions
and
7 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
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,25 @@ | ||
FROM node:6 | ||
|
||
RUN apt-get update | ||
RUN apt-get install --yes python2.7 git-all pkg-config libncurses5-dev libssl-dev libnss3-dev libexpat-dev libc6 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY package.json /usr/src/app/package.json | ||
|
||
RUN npm install | ||
RUN npm install wrtc | ||
|
||
COPY . /usr/src/app | ||
|
||
ENV IPFS_WRTC_LINUX_WINDOWS=1 | ||
ENV IPFS_BOOTSTRAP=1 | ||
ENV IPFS_MONITORING=1 | ||
ENV IPFS_PATH=/root/.jsipfs | ||
|
||
EXPOSE 4002 | ||
EXPOSE 4003 | ||
EXPOSE 5002 | ||
EXPOSE 9090 | ||
|
||
CMD ./init-and-daemon.sh |
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,6 @@ | ||
#! /bin/sh -e | ||
node src/cli/bin.js init | ||
|
||
sed -i.bak 's/127.0.0.1/0.0.0.0/g' $IPFS_PATH/config | ||
|
||
node src/cli/bin.js daemon |
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,31 @@ | ||
'use strict' | ||
|
||
const register = require('prom-client').register | ||
const client = require('prom-client') | ||
|
||
// Endpoint for handling debug metrics | ||
module.exports = (server) => { | ||
const api = server.select('API') | ||
// Clear the register to make sure we're not registering multiple ones | ||
register.clear() | ||
const gauge = new client.Gauge({ name: 'number_of_peers', help: 'the_number_of_currently_connected_peers' }) | ||
|
||
api.route({ | ||
method: 'GET', | ||
path: '/debug/metrics/prometheus', | ||
handler: (request, reply) => { | ||
if (!process.env.IPFS_MONITORING) { | ||
return reply('Monitoring is disabled. Enable it by setting environment variable IPFS_MONITORING') | ||
.code(501) // 501 = Not Implemented | ||
} | ||
server.app.ipfs.swarm.peers((err, res) => { | ||
if (err) { | ||
return reply(err).code(500) | ||
} | ||
const count = res.length | ||
gauge.set(count) | ||
reply(register.metrics()).header('Content-Type', register.contentType) | ||
}) | ||
} | ||
}) | ||
} |
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