├── server
├── static
│ └── .gitkeep
├── .eslintignore
├── config
│ ├── prod.env.js
│ ├── dev.env.js
│ └── index.js
├── src
│ ├── assets
│ │ └── logo.png
│ ├── router
│ │ └── index.js
│ ├── App.vue
│ ├── main.js
│ └── components
│ │ └── Hello.vue
├── .editorconfig
├── .gitignore
├── .postcssrc.js
├── plugins
│ ├── miner
│ │ ├── index.js
│ │ └── render.vue
│ ├── monitor
│ │ └── index.js
│ ├── zcash-usd
│ │ ├── render.js
│ │ └── index.js
│ └── pool
│ │ ├── index.js
│ │ └── render.js
├── build
│ ├── dev-client.js
│ ├── vue-loader.conf.js
│ ├── build.js
│ ├── webpack.dev.conf.js
│ ├── check-versions.js
│ ├── webpack.base.conf.js
│ ├── utils.js
│ ├── dev-server.js
│ └── webpack.prod.conf.js
├── index.html
├── .babelrc
├── README.md
├── .eslintrc.js
├── index.js
└── package.json
├── README.md
├── package.json
├── LICENSE
├── .gitignore
└── client
└── client.js
/server/static/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/server/.eslintignore:
--------------------------------------------------------------------------------
1 | build/*.js
2 | config/*.js
3 |
--------------------------------------------------------------------------------
/server/config/prod.env.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | NODE_ENV: '"production"'
3 | }
4 |
--------------------------------------------------------------------------------
/server/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rijn/mining-monitor/master/server/src/assets/logo.png
--------------------------------------------------------------------------------
/server/config/dev.env.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var prodEnv = require('./prod.env')
3 |
4 | module.exports = merge(prodEnv, {
5 | NODE_ENV: '"development"'
6 | })
7 |
--------------------------------------------------------------------------------
/server/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/server/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | dist/
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Editor directories and files
9 | .idea
10 | *.suo
11 | *.ntvs*
12 | *.njsproj
13 | *.sln
14 |
--------------------------------------------------------------------------------
/server/.postcssrc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/michael-ciniawsky/postcss-load-config
2 |
3 | module.exports = {
4 | "plugins": {
5 | // to edit target browsers: use "browserslist" field in package.json
6 | "autoprefixer": {}
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/server/plugins/miner/index.js:
--------------------------------------------------------------------------------
1 | module.exports = ({ bus, socket = null }) => {
2 | if (!socket) return;
3 |
4 | socket.on('upstream', function (m) {
5 | m.time = (new Date()).toISOString();
6 | bus.push({ module: 'miner', message: m });
7 | });
8 | };
9 |
--------------------------------------------------------------------------------
/server/build/dev-client.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | require('eventsource-polyfill')
3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4 |
5 | hotClient.subscribe(function (event) {
6 | if (event.action === 'reload') {
7 | window.location.reload()
8 | }
9 | })
10 |
--------------------------------------------------------------------------------
/server/src/router/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Router from 'vue-router'
3 | import Hello from '@/components/Hello'
4 |
5 | Vue.use(Router)
6 |
7 | export default new Router({
8 | routes: [
9 | {
10 | path: '/',
11 | name: 'Hello',
12 | component: Hello
13 | }
14 | ]
15 | })
16 |
--------------------------------------------------------------------------------
/server/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | mining-monitor
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/server/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", {
4 | "modules": false,
5 | "targets": {
6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7 | }
8 | }],
9 | "stage-2"
10 | ],
11 | "plugins": ["transform-runtime"],
12 | "env": {
13 | "test": {
14 | "presets": ["env", "stage-2"],
15 | "plugins": ["istanbul"]
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/server/plugins/monitor/index.js:
--------------------------------------------------------------------------------
1 | module.exports = ({ bus, socket = null, io }) => {
2 | if (!socket) return;
3 |
4 | socket.on('register', function () {
5 | socket.join('monitor');
6 |
7 | if (!io.pushService) {
8 | io.pushService = setInterval(function () {
9 | if (bus.empty()) return;
10 | io.to('monitor').emit('downstream', bus.pull());
11 | bus.flush();
12 | }, 2000);
13 | }
14 | });
15 | };
16 |
--------------------------------------------------------------------------------
/server/build/vue-loader.conf.js:
--------------------------------------------------------------------------------
1 | var utils = require('./utils')
2 | var config = require('../config')
3 | var isProduction = process.env.NODE_ENV === 'production'
4 |
5 | module.exports = {
6 | loaders: utils.cssLoaders({
7 | sourceMap: isProduction
8 | ? config.build.productionSourceMap
9 | : config.dev.cssSourceMap,
10 | extract: isProduction
11 | }),
12 | transformToRequire: {
13 | video: 'src',
14 | source: 'src',
15 | img: 'src',
16 | image: 'xlink:href'
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/server/README.md:
--------------------------------------------------------------------------------
1 | # mining-monitor
2 |
3 | > mining-monitor
4 |
5 | ## Build Setup
6 |
7 | ``` bash
8 | # install dependencies
9 | npm install
10 |
11 | # serve with hot reload at localhost:8080
12 | npm run dev
13 |
14 | # build for production with minification
15 | npm run build
16 |
17 | # build for production and view the bundle analyzer report
18 | npm run build --report
19 | ```
20 |
21 | For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
22 |
--------------------------------------------------------------------------------
/server/plugins/zcash-usd/render.js:
--------------------------------------------------------------------------------
1 | export default {
2 | name: 'zcash-usd',
3 |
4 | template: `
5 |
1 ZEC : {{ ZECUSD }} USD
6 |
`,
7 |
8 | data () {
9 | return {
10 | line: [],
11 | ZECUSD: 'pending'
12 | }
13 | },
14 |
15 | created () {
16 | this.$bus.on(this.$options.name, this.process)
17 | },
18 | beforeDestroy () {
19 | this.$bus.off(this.$options.name, this.process)
20 | },
21 |
22 | methods: {
23 | process ({ time, ZECUSD }) {
24 | this.ZECUSD = ZECUSD;
25 | // this.line.push({ time, ZECUSD });
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # mining-monitor
2 |
3 | ## Protocal
4 |
5 | ### Miner status
6 |
7 | #### Fields
8 |
9 | * Name
10 | * IP
11 | * Server
12 | * Ping
13 | * GPUs
14 | * GPUs.Name
15 | * GPUs.Temp
16 | * GPUs.Watt
17 | * GPUs.Speed
18 | * GPUs.Efficiency
19 |
20 | _Example_
21 |
22 | ```json
23 | {
24 | "name": "Columbus",
25 | "ip": "...",
26 | "server": "us1-...",
27 | "ping": 123, /* ms */
28 | "gpus": [{
29 | "name": "GTX 1080 Ti",
30 | "temperature": 74.9, /* c */
31 | "watt": 113, /* W */
32 | "speed": 288 /* Sol/s */
33 | }]
34 | }
35 | ```
--------------------------------------------------------------------------------
/server/plugins/zcash-usd/index.js:
--------------------------------------------------------------------------------
1 | const rp = require('request-promise');
2 |
3 | module.exports = ({ bus }) => {
4 | var apiCall = () => {
5 | return rp({
6 | uri: 'https://api.kraken.com/0/public/Spread?pair=ZECUSD',
7 | json: true
8 | })
9 | .then(response => {
10 | let ZECUSD = response.result.XZECZUSD[response.result.XZECZUSD.length - 1][1];
11 | let time = (new Date()).toISOString();
12 | bus.push({ module: 'zcash-usd', message: { ZECUSD, time } });
13 | })
14 | .catch(err => {
15 | console.error(err);
16 | res.status(500).end();
17 | });
18 | };
19 |
20 | setInterval(apiCall, 5000);
21 | };
22 |
--------------------------------------------------------------------------------
/server/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // http://eslint.org/docs/user-guide/configuring
2 |
3 | module.exports = {
4 | root: true,
5 | parser: 'babel-eslint',
6 | parserOptions: {
7 | sourceType: 'module'
8 | },
9 | env: {
10 | browser: true,
11 | },
12 | // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
13 | extends: 'standard',
14 | // required to lint *.vue files
15 | plugins: [
16 | 'html'
17 | ],
18 | // add your custom rules here
19 | 'rules': {
20 | // allow paren-less arrow functions
21 | 'arrow-parens': 0,
22 | // allow async-await
23 | 'generator-star-spacing': 0,
24 | // allow debugger during development
25 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mining-monitor",
3 | "version": "0.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/rijn/mining-monitor.git"
12 | },
13 | "author": "",
14 | "license": "MIT",
15 | "bugs": {
16 | "url": "https://github.com/rijn/mining-monitor/issues"
17 | },
18 | "homepage": "https://github.com/rijn/mining-monitor#readme",
19 | "dependencies": {
20 | "bluebird": "^3.5.0",
21 | "express": "^4.15.3",
22 | "lodash": "^4.17.4",
23 | "ping": "^0.2.2",
24 | "pug": "^2.0.0-rc.2",
25 | "request": "^2.81.0",
26 | "request-promise": "^4.2.1"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/server/plugins/pool/index.js:
--------------------------------------------------------------------------------
1 | const rp = require('request-promise');
2 |
3 | module.exports = ({ bus }) => {
4 | var apiCall = () => {
5 | return rp({
6 | uri: 'http://zcash.flypool.org/api/miner_new/t1STYd26FqHnyay37yjf94qi9nxG3GFtfzL',
7 | json: true
8 | })
9 | .then(response => {
10 | let earned = (response.payouts.reduce((acc, item) => acc + item.amount, 0.0) * 1e-8).toFixed(6);
11 | let unpaid = (response.unpaid * 1e-8).toFixed(6);
12 | let time = (new Date()).toISOString();
13 | bus.push({ module: 'pool', message: { time, earned, unpaid } });
14 | })
15 | .catch(err => {
16 | console.error(err);
17 | res.status(500).end();
18 | });
19 | };
20 |
21 | setInterval(apiCall, 10000);
22 | apiCall();
23 | };
24 |
--------------------------------------------------------------------------------
/server/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
13 |
14 |
46 |
--------------------------------------------------------------------------------
/server/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueBus from 'vue-bus'
3 | import VueSocketio from 'vue-socket.io'
4 | import App from './App'
5 | import router from './router'
6 |
7 | import 'normalize.css'
8 |
9 | Vue.use(VueSocketio, '/')
10 | Vue.use(VueBus)
11 |
12 | Vue.config.productionTip = false
13 |
14 | /* eslint-disable no-new */
15 | new Vue({
16 | sockets: {
17 | connect () {
18 | this.$bus.emit('connectivity', true)
19 | this.$socket.emit('register')
20 | },
21 | disconnect () {
22 | this.$bus.emit('connectivity', false)
23 | },
24 | downstream (data) {
25 | this.$bus.emit('connectivity', true)
26 | data.forEach(({ module, message }) => {
27 | this.$bus.emit(module, message)
28 | })
29 | }
30 | },
31 | el: '#app',
32 | router,
33 | template: '',
34 | components: { App }
35 | })
36 |
--------------------------------------------------------------------------------
/server/plugins/pool/render.js:
--------------------------------------------------------------------------------
1 | export default {
2 | name: 'pool',
3 |
4 | template: `
5 |
EARNED : {{ earned }} ZEC
6 |
UNPAID : {{ unpaid }} ZEC
7 |
$ {{ usd }}
8 |
`,
9 |
10 | data () {
11 | return {
12 | earned: 'pending',
13 | unpaid: 'pending',
14 | ZECUSD: 'pending'
15 | }
16 | },
17 |
18 | computed: {
19 | usd: function () {
20 | return ((Number(this.earned) + Number(this.unpaid)) * Number(this.ZECUSD)).toFixed(2);
21 | }
22 | },
23 |
24 | created () {
25 | this.$bus.on(this.$options.name, this.process)
26 | this.$bus.on('zcash-usd', this.exchange)
27 | },
28 | beforeDestroy () {
29 | this.$bus.off(this.$options.name, this.process)
30 | this.$bus.off('zcash-usd', this.exchange)
31 | },
32 |
33 | methods: {
34 | process ({ earned, unpaid }) {
35 | this.earned = earned;
36 | this.unpaid = unpaid;
37 | },
38 | exchange ({ ZECUSD }) {
39 | this.ZECUSD = ZECUSD;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/server/index.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var app = express();
3 | var http = require('http').Server(app);
4 | var io = require('socket.io')(http);
5 | var path = require('path');
6 |
7 | var bus = ((() => {
8 | var Bus = function () {
9 | this.queue = [];
10 | };
11 |
12 | Bus.prototype.push = function (m) {
13 | this.queue.push(m);
14 | };
15 |
16 | Bus.prototype.pull = function () {
17 | return this.queue;
18 | };
19 |
20 | Bus.prototype.flush = function () {
21 | this.queue = [];
22 | };
23 |
24 | Bus.prototype.empty = function () {
25 | return !this.queue.length
26 | };
27 |
28 | return new Bus();
29 | })());
30 |
31 | app.use('/', express.static(path.join(__dirname, 'dist')));
32 |
33 | require('./plugins/zcash-usd')({ bus, io });
34 | require('./plugins/pool')({ bus, io });
35 |
36 | io.on('connection', function (socket) {
37 | require('./plugins/miner')({ bus, socket });
38 | require('./plugins/monitor')({ bus, socket, io });
39 | });
40 |
41 | http.listen(3000, function(){
42 | console.log('listening on *:3000');
43 | });
44 |
--------------------------------------------------------------------------------
/server/build/build.js:
--------------------------------------------------------------------------------
1 | require('./check-versions')()
2 |
3 | process.env.NODE_ENV = 'production'
4 |
5 | var ora = require('ora')
6 | var rm = require('rimraf')
7 | var path = require('path')
8 | var chalk = require('chalk')
9 | var webpack = require('webpack')
10 | var config = require('../config')
11 | var webpackConfig = require('./webpack.prod.conf')
12 |
13 | var spinner = ora('building for production...')
14 | spinner.start()
15 |
16 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
17 | if (err) throw err
18 | webpack(webpackConfig, function (err, stats) {
19 | spinner.stop()
20 | if (err) throw err
21 | process.stdout.write(stats.toString({
22 | colors: true,
23 | modules: false,
24 | children: false,
25 | chunks: false,
26 | chunkModules: false
27 | }) + '\n\n')
28 |
29 | console.log(chalk.cyan(' Build complete.\n'))
30 | console.log(chalk.yellow(
31 | ' Tip: built files are meant to be served over an HTTP server.\n' +
32 | ' Opening index.html over file:// won\'t work.\n'
33 | ))
34 | })
35 | })
36 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Rijn Bian
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 | *.pid.lock
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # Bower dependency directory (https://bower.io/)
27 | bower_components
28 |
29 | # node-waf configuration
30 | .lock-wscript
31 |
32 | # Compiled binary addons (http://nodejs.org/api/addons.html)
33 | build/Release
34 |
35 | # Dependency directories
36 | node_modules/
37 | jspm_packages/
38 |
39 | # Typescript v1 declaration files
40 | typings/
41 |
42 | # Optional npm cache directory
43 | .npm
44 |
45 | # Optional eslint cache
46 | .eslintcache
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
51 | # Output of 'npm pack'
52 | *.tgz
53 |
54 | # Yarn Integrity file
55 | .yarn-integrity
56 |
57 | # dotenv environment variables file
58 | .env
59 |
60 |
--------------------------------------------------------------------------------
/server/build/webpack.dev.conf.js:
--------------------------------------------------------------------------------
1 | var utils = require('./utils')
2 | var webpack = require('webpack')
3 | var config = require('../config')
4 | var merge = require('webpack-merge')
5 | var baseWebpackConfig = require('./webpack.base.conf')
6 | var HtmlWebpackPlugin = require('html-webpack-plugin')
7 | var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
8 |
9 | // add hot-reload related code to entry chunks
10 | Object.keys(baseWebpackConfig.entry).forEach(function (name) {
11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
12 | })
13 |
14 | module.exports = merge(baseWebpackConfig, {
15 | module: {
16 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
17 | },
18 | // cheap-module-eval-source-map is faster for development
19 | devtool: '#cheap-module-eval-source-map',
20 | plugins: [
21 | new webpack.DefinePlugin({
22 | 'process.env': config.dev.env
23 | }),
24 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
25 | new webpack.HotModuleReplacementPlugin(),
26 | new webpack.NoEmitOnErrorsPlugin(),
27 | // https://github.com/ampedandwired/html-webpack-plugin
28 | new HtmlWebpackPlugin({
29 | filename: 'index.html',
30 | template: 'index.html',
31 | inject: true
32 | }),
33 | new FriendlyErrorsPlugin()
34 | ]
35 | })
36 |
--------------------------------------------------------------------------------
/server/build/check-versions.js:
--------------------------------------------------------------------------------
1 | var chalk = require('chalk')
2 | var semver = require('semver')
3 | var packageConfig = require('../package.json')
4 | var shell = require('shelljs')
5 | function exec (cmd) {
6 | return require('child_process').execSync(cmd).toString().trim()
7 | }
8 |
9 | var versionRequirements = [
10 | {
11 | name: 'node',
12 | currentVersion: semver.clean(process.version),
13 | versionRequirement: packageConfig.engines.node
14 | },
15 | ]
16 |
17 | if (shell.which('npm')) {
18 | versionRequirements.push({
19 | name: 'npm',
20 | currentVersion: exec('npm --version'),
21 | versionRequirement: packageConfig.engines.npm
22 | })
23 | }
24 |
25 | module.exports = function () {
26 | var warnings = []
27 | for (var i = 0; i < versionRequirements.length; i++) {
28 | var mod = versionRequirements[i]
29 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
30 | warnings.push(mod.name + ': ' +
31 | chalk.red(mod.currentVersion) + ' should be ' +
32 | chalk.green(mod.versionRequirement)
33 | )
34 | }
35 | }
36 |
37 | if (warnings.length) {
38 | console.log('')
39 | console.log(chalk.yellow('To use this template, you must update following to modules:'))
40 | console.log()
41 | for (var i = 0; i < warnings.length; i++) {
42 | var warning = warnings[i]
43 | console.log(' ' + warning)
44 | }
45 | console.log()
46 | process.exit(1)
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/server/src/components/Hello.vue:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
42 |
43 |
44 |
72 |
--------------------------------------------------------------------------------
/server/config/index.js:
--------------------------------------------------------------------------------
1 | // see http://vuejs-templates.github.io/webpack for documentation.
2 | var path = require('path')
3 |
4 | module.exports = {
5 | build: {
6 | env: require('./prod.env'),
7 | index: path.resolve(__dirname, '../dist/index.html'),
8 | assetsRoot: path.resolve(__dirname, '../dist'),
9 | assetsSubDirectory: 'static',
10 | assetsPublicPath: '/',
11 | productionSourceMap: true,
12 | // Gzip off by default as many popular static hosts such as
13 | // Surge or Netlify already gzip all static assets for you.
14 | // Before setting to `true`, make sure to:
15 | // npm install --save-dev compression-webpack-plugin
16 | productionGzip: false,
17 | productionGzipExtensions: ['js', 'css'],
18 | // Run the build command with an extra argument to
19 | // View the bundle analyzer report after build finishes:
20 | // `npm run build --report`
21 | // Set to `true` or `false` to always turn it on or off
22 | bundleAnalyzerReport: process.env.npm_config_report
23 | },
24 | dev: {
25 | env: require('./dev.env'),
26 | port: 8080,
27 | autoOpenBrowser: true,
28 | assetsSubDirectory: 'static',
29 | assetsPublicPath: '/',
30 | proxyTable: {},
31 | // CSS Sourcemaps off by default because relative paths are "buggy"
32 | // with this option, according to the CSS-Loader README
33 | // (https://github.com/webpack/css-loader#sourcemaps)
34 | // In our experience, they generally work as expected,
35 | // just be aware of this issue when enabling this option.
36 | cssSourceMap: false
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/server/plugins/miner/render.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 | {{ miner.name }}
6 | PING{{ miner.ping }}
7 | LAST{{ (current - miner.time).toFixed(0) }}
8 |
9 | -
10 | {{ gpu.name }}
11 | SOL/s{{ gpu.speed }}
12 | C{{ gpu.temperature }}
13 | W{{ gpu.watt }}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
54 |
55 |
75 |
--------------------------------------------------------------------------------
/client/client.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const io = require('socket.io-client');
3 | var express = require("express");
4 | var app = express();
5 | var http = require('http');
6 | var ip = require("ip");
7 | var ping = require('ping');
8 | var rp = require('request-promise');
9 |
10 | var url = 'http://192.168.1.138:3150';
11 | const socket = io(url);
12 |
13 | setInterval(function(){
14 |
15 | var host = 'us1-zcash.flypool.org';
16 |
17 | Promise.all([
18 | rp({
19 | uri: 'http://localhost:42000/getstat',
20 | json: true
21 | }),
22 | ping.promise.probe(host)]
23 | ).then(values => {
24 | socket.emit('chat message',{
25 | 'name': 'test',
26 | 'ip': ip.address(),
27 | 'server': values[0].current_server,
28 | 'ping': values[1].time,
29 | 'gpus': values[0].result.map(gpu => { return {
30 | name: gpu.name,
31 | temperature: gpu.temperature,
32 | watt: gpu.gpu_power_usage,
33 | speed: gpu.speed_sps
34 | };})
35 | })
36 | });
37 |
38 | }, 5000);
39 | /*
40 | http.get(options, function(res){
41 | var json = '';
42 | res.on('data', function (chunk) {
43 | json += chunk;
44 | });
45 |
46 | res.on('end', function(){
47 | if (res.statusCode === 200){
48 | try{
49 | var data = JSON.parse(json);
50 | socket.emit('upstream',{
51 | 'name': data.name,
52 | 'ip': ip.address(),
53 | 'server': data.current_server,
54 |
55 | })
56 |
57 | }
58 | catch(e){
59 | console.log('Error parsing JSON!');
60 | }
61 | }
62 | else{
63 | console.log('Status:', res.statusCode);
64 | }
65 | });
66 | }).on('error', function(err){
67 | console.log('Error:', err);
68 | });
69 |
70 | function sendJson(data){
71 |
72 | }
73 | */
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/server/build/webpack.base.conf.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var utils = require('./utils')
3 | var config = require('../config')
4 | var vueLoaderConfig = require('./vue-loader.conf')
5 |
6 | function resolve (dir) {
7 | return path.join(__dirname, '..', dir)
8 | }
9 |
10 | module.exports = {
11 | entry: {
12 | app: './src/main.js'
13 | },
14 | output: {
15 | path: config.build.assetsRoot,
16 | filename: '[name].js',
17 | publicPath: process.env.NODE_ENV === 'production'
18 | ? config.build.assetsPublicPath
19 | : config.dev.assetsPublicPath
20 | },
21 | resolve: {
22 | extensions: ['.js', '.vue', '.json'],
23 | alias: {
24 | 'vue$': 'vue/dist/vue.esm.js',
25 | '@': resolve('src')
26 | }
27 | },
28 | module: {
29 | rules: [
30 | {
31 | test: /\.(js|vue)$/,
32 | loader: 'eslint-loader',
33 | enforce: 'pre',
34 | include: [resolve('src'), resolve('test')],
35 | options: {
36 | formatter: require('eslint-friendly-formatter')
37 | }
38 | },
39 | {
40 | test: /\.vue$/,
41 | loader: 'vue-loader',
42 | options: vueLoaderConfig
43 | },
44 | {
45 | test: /\.js$/,
46 | loader: 'babel-loader',
47 | include: [resolve('src'), resolve('test')]
48 | },
49 | {
50 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
51 | loader: 'url-loader',
52 | options: {
53 | limit: 10000,
54 | name: utils.assetsPath('img/[name].[hash:7].[ext]')
55 | }
56 | },
57 | {
58 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
59 | loader: 'url-loader',
60 | options: {
61 | limit: 10000,
62 | name: utils.assetsPath('media/[name].[hash:7].[ext]')
63 | }
64 | },
65 | {
66 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
67 | loader: 'url-loader',
68 | options: {
69 | limit: 10000,
70 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
71 | }
72 | }
73 | ]
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/server/build/utils.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var config = require('../config')
3 | var ExtractTextPlugin = require('extract-text-webpack-plugin')
4 |
5 | exports.assetsPath = function (_path) {
6 | var assetsSubDirectory = process.env.NODE_ENV === 'production'
7 | ? config.build.assetsSubDirectory
8 | : config.dev.assetsSubDirectory
9 | return path.posix.join(assetsSubDirectory, _path)
10 | }
11 |
12 | exports.cssLoaders = function (options) {
13 | options = options || {}
14 |
15 | var cssLoader = {
16 | loader: 'css-loader',
17 | options: {
18 | minimize: process.env.NODE_ENV === 'production',
19 | sourceMap: options.sourceMap
20 | }
21 | }
22 |
23 | // generate loader string to be used with extract text plugin
24 | function generateLoaders (loader, loaderOptions) {
25 | var loaders = [cssLoader]
26 | if (loader) {
27 | loaders.push({
28 | loader: loader + '-loader',
29 | options: Object.assign({}, loaderOptions, {
30 | sourceMap: options.sourceMap
31 | })
32 | })
33 | }
34 |
35 | // Extract CSS when that option is specified
36 | // (which is the case during production build)
37 | if (options.extract) {
38 | return ExtractTextPlugin.extract({
39 | use: loaders,
40 | fallback: 'vue-style-loader'
41 | })
42 | } else {
43 | return ['vue-style-loader'].concat(loaders)
44 | }
45 | }
46 |
47 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html
48 | return {
49 | css: generateLoaders(),
50 | postcss: generateLoaders(),
51 | less: generateLoaders('less'),
52 | sass: generateLoaders('sass', { indentedSyntax: true }),
53 | scss: generateLoaders('sass'),
54 | stylus: generateLoaders('stylus'),
55 | styl: generateLoaders('stylus')
56 | }
57 | }
58 |
59 | // Generate loaders for standalone style files (outside of .vue)
60 | exports.styleLoaders = function (options) {
61 | var output = []
62 | var loaders = exports.cssLoaders(options)
63 | for (var extension in loaders) {
64 | var loader = loaders[extension]
65 | output.push({
66 | test: new RegExp('\\.' + extension + '$'),
67 | use: loader
68 | })
69 | }
70 | return output
71 | }
72 |
--------------------------------------------------------------------------------
/server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mining-monitor",
3 | "version": "1.0.0",
4 | "description": "mining-monitor",
5 | "author": "Rijn ",
6 | "private": true,
7 | "scripts": {
8 | "dev": "node build/dev-server.js",
9 | "start": "node build/dev-server.js",
10 | "build": "node build/build.js",
11 | "lint": "eslint --ext .js,.vue src"
12 | },
13 | "dependencies": {
14 | "express": "^4.15.3",
15 | "less": "^2.7.2",
16 | "less-loader": "^4.0.5",
17 | "normalize.css": "^7.0.0",
18 | "request-promise": "^4.2.1",
19 | "socket.io": "^2.0.3",
20 | "vue": "^2.3.3",
21 | "vue-bus": "^1.0.0",
22 | "vue-router": "^2.6.0",
23 | "vue-socket.io": "^2.1.1-a"
24 | },
25 | "devDependencies": {
26 | "autoprefixer": "^7.1.2",
27 | "babel-core": "^6.22.1",
28 | "babel-eslint": "^7.1.1",
29 | "babel-loader": "^7.1.1",
30 | "babel-plugin-transform-runtime": "^6.22.0",
31 | "babel-preset-env": "^1.3.2",
32 | "babel-preset-stage-2": "^6.22.0",
33 | "babel-register": "^6.22.0",
34 | "chalk": "^2.0.1",
35 | "connect-history-api-fallback": "^1.3.0",
36 | "copy-webpack-plugin": "^4.0.1",
37 | "css-loader": "^0.28.0",
38 | "cssnano": "^3.10.0",
39 | "eslint": "^3.19.0",
40 | "eslint-friendly-formatter": "^3.0.0",
41 | "eslint-loader": "^1.7.1",
42 | "eslint-plugin-html": "^3.0.0",
43 | "eslint-config-standard": "^6.2.1",
44 | "eslint-plugin-promise": "^3.4.0",
45 | "eslint-plugin-standard": "^2.0.1",
46 | "eventsource-polyfill": "^0.9.6",
47 | "express": "^4.14.1",
48 | "extract-text-webpack-plugin": "^2.0.0",
49 | "file-loader": "^0.11.1",
50 | "friendly-errors-webpack-plugin": "^1.1.3",
51 | "html-webpack-plugin": "^2.28.0",
52 | "http-proxy-middleware": "^0.17.3",
53 | "webpack-bundle-analyzer": "^2.2.1",
54 | "semver": "^5.3.0",
55 | "shelljs": "^0.7.6",
56 | "opn": "^5.1.0",
57 | "optimize-css-assets-webpack-plugin": "^2.0.0",
58 | "ora": "^1.2.0",
59 | "rimraf": "^2.6.0",
60 | "url-loader": "^0.5.8",
61 | "vue-loader": "^12.1.0",
62 | "vue-style-loader": "^3.0.1",
63 | "vue-template-compiler": "^2.3.3",
64 | "webpack": "^2.6.1",
65 | "webpack-dev-middleware": "^1.10.0",
66 | "webpack-hot-middleware": "^2.18.0",
67 | "webpack-merge": "^4.1.0"
68 | },
69 | "engines": {
70 | "node": ">= 4.0.0",
71 | "npm": ">= 3.0.0"
72 | },
73 | "browserslist": [
74 | "> 1%",
75 | "last 2 versions",
76 | "not ie <= 8"
77 | ]
78 | }
79 |
--------------------------------------------------------------------------------
/server/build/dev-server.js:
--------------------------------------------------------------------------------
1 | require('./check-versions')()
2 |
3 | var config = require('../config')
4 | if (!process.env.NODE_ENV) {
5 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
6 | }
7 |
8 | var opn = require('opn')
9 | var path = require('path')
10 | var express = require('express')
11 | var webpack = require('webpack')
12 | var proxyMiddleware = require('http-proxy-middleware')
13 | var webpackConfig = require('./webpack.dev.conf')
14 |
15 | // default port where dev server listens for incoming traffic
16 | var port = process.env.PORT || config.dev.port
17 | // automatically open browser, if not set will be false
18 | var autoOpenBrowser = !!config.dev.autoOpenBrowser
19 | // Define HTTP proxies to your custom API backend
20 | // https://github.com/chimurai/http-proxy-middleware
21 | var proxyTable = config.dev.proxyTable
22 |
23 | var app = express()
24 | var compiler = webpack(webpackConfig)
25 |
26 | var devMiddleware = require('webpack-dev-middleware')(compiler, {
27 | publicPath: webpackConfig.output.publicPath,
28 | quiet: true
29 | })
30 |
31 | var hotMiddleware = require('webpack-hot-middleware')(compiler, {
32 | log: () => {},
33 | heartbeat: 2000
34 | })
35 | // force page reload when html-webpack-plugin template changes
36 | compiler.plugin('compilation', function (compilation) {
37 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
38 | hotMiddleware.publish({ action: 'reload' })
39 | cb()
40 | })
41 | })
42 |
43 | // proxy api requests
44 | Object.keys(proxyTable).forEach(function (context) {
45 | var options = proxyTable[context]
46 | if (typeof options === 'string') {
47 | options = { target: options }
48 | }
49 | app.use(proxyMiddleware(options.filter || context, options))
50 | })
51 |
52 | // handle fallback for HTML5 history API
53 | app.use(require('connect-history-api-fallback')())
54 |
55 | // serve webpack bundle output
56 | app.use(devMiddleware)
57 |
58 | // enable hot-reload and state-preserving
59 | // compilation error display
60 | app.use(hotMiddleware)
61 |
62 | // serve pure static assets
63 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
64 | app.use(staticPath, express.static('./static'))
65 |
66 | var uri = 'http://localhost:' + port
67 |
68 | var _resolve
69 | var readyPromise = new Promise(resolve => {
70 | _resolve = resolve
71 | })
72 |
73 | console.log('> Starting dev server...')
74 | devMiddleware.waitUntilValid(() => {
75 | console.log('> Listening at ' + uri + '\n')
76 | // when env is testing, don't need open it
77 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
78 | opn(uri)
79 | }
80 | _resolve()
81 | })
82 |
83 | var server = app.listen(port)
84 |
85 | module.exports = {
86 | ready: readyPromise,
87 | close: () => {
88 | server.close()
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/server/build/webpack.prod.conf.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var utils = require('./utils')
3 | var webpack = require('webpack')
4 | var config = require('../config')
5 | var merge = require('webpack-merge')
6 | var baseWebpackConfig = require('./webpack.base.conf')
7 | var CopyWebpackPlugin = require('copy-webpack-plugin')
8 | var HtmlWebpackPlugin = require('html-webpack-plugin')
9 | var ExtractTextPlugin = require('extract-text-webpack-plugin')
10 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
11 |
12 | var env = config.build.env
13 |
14 | var webpackConfig = merge(baseWebpackConfig, {
15 | module: {
16 | rules: utils.styleLoaders({
17 | sourceMap: config.build.productionSourceMap,
18 | extract: true
19 | })
20 | },
21 | devtool: config.build.productionSourceMap ? '#source-map' : false,
22 | output: {
23 | path: config.build.assetsRoot,
24 | filename: utils.assetsPath('js/[name].[chunkhash].js'),
25 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
26 | },
27 | plugins: [
28 | // http://vuejs.github.io/vue-loader/en/workflow/production.html
29 | new webpack.DefinePlugin({
30 | 'process.env': env
31 | }),
32 | new webpack.optimize.UglifyJsPlugin({
33 | compress: {
34 | warnings: false
35 | },
36 | sourceMap: true
37 | }),
38 | // extract css into its own file
39 | new ExtractTextPlugin({
40 | filename: utils.assetsPath('css/[name].[contenthash].css')
41 | }),
42 | // Compress extracted CSS. We are using this plugin so that possible
43 | // duplicated CSS from different components can be deduped.
44 | new OptimizeCSSPlugin({
45 | cssProcessorOptions: {
46 | safe: true
47 | }
48 | }),
49 | // generate dist index.html with correct asset hash for caching.
50 | // you can customize output by editing /index.html
51 | // see https://github.com/ampedandwired/html-webpack-plugin
52 | new HtmlWebpackPlugin({
53 | filename: config.build.index,
54 | template: 'index.html',
55 | inject: true,
56 | minify: {
57 | removeComments: true,
58 | collapseWhitespace: true,
59 | removeAttributeQuotes: true
60 | // more options:
61 | // https://github.com/kangax/html-minifier#options-quick-reference
62 | },
63 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin
64 | chunksSortMode: 'dependency'
65 | }),
66 | // split vendor js into its own file
67 | new webpack.optimize.CommonsChunkPlugin({
68 | name: 'vendor',
69 | minChunks: function (module, count) {
70 | // any required modules inside node_modules are extracted to vendor
71 | return (
72 | module.resource &&
73 | /\.js$/.test(module.resource) &&
74 | module.resource.indexOf(
75 | path.join(__dirname, '../node_modules')
76 | ) === 0
77 | )
78 | }
79 | }),
80 | // extract webpack runtime and module manifest to its own file in order to
81 | // prevent vendor hash from being updated whenever app bundle is updated
82 | new webpack.optimize.CommonsChunkPlugin({
83 | name: 'manifest',
84 | chunks: ['vendor']
85 | }),
86 | // copy custom static assets
87 | new CopyWebpackPlugin([
88 | {
89 | from: path.resolve(__dirname, '../static'),
90 | to: config.build.assetsSubDirectory,
91 | ignore: ['.*']
92 | }
93 | ])
94 | ]
95 | })
96 |
97 | if (config.build.productionGzip) {
98 | var CompressionWebpackPlugin = require('compression-webpack-plugin')
99 |
100 | webpackConfig.plugins.push(
101 | new CompressionWebpackPlugin({
102 | asset: '[path].gz[query]',
103 | algorithm: 'gzip',
104 | test: new RegExp(
105 | '\\.(' +
106 | config.build.productionGzipExtensions.join('|') +
107 | ')$'
108 | ),
109 | threshold: 10240,
110 | minRatio: 0.8
111 | })
112 | )
113 | }
114 |
115 | if (config.build.bundleAnalyzerReport) {
116 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
117 | webpackConfig.plugins.push(new BundleAnalyzerPlugin())
118 | }
119 |
120 | module.exports = webpackConfig
121 |
--------------------------------------------------------------------------------