Skip to content
Snippets Groups Projects
Select Git revision
  • aa7a99cfd0e083017bd79d4613f1312bf850e3f7
  • master default protected
  • 3-regression-l-onglet-network-reste-vide
  • v1.7.5 protected
  • v1.7.4 protected
  • v1.7.3 protected
  • v1.7.2 protected
  • v1.7.1 protected
  • v1.7.0 protected
  • v1.6.31 protected
  • v1.6.30 protected
  • v1.6.29 protected
  • v1.6.28 protected
  • v1.6.27 protected
  • v1.6.26 protected
  • v1.6.25 protected
  • v1.6.24 protected
  • v1.6.23 protected
  • v1.6.22 protected
  • v1.6.21 protected
  • v1.6.20 protected
  • v1.6.19 protected
  • v1.6.18 protected
23 results

index.js

Blame
  • index.js 5.97 KiB
    "use strict";
    
    const _ = require('underscore')
    const co = require('co');
    const fs = require('fs');
    const bodyParser = require('body-parser');
    const http    = require('http');
    const express = require('express');
    const path    = require('path');
    const cors = require('cors');
    const fileUpload = require('express-fileupload');
    const webminController = require('./server/controller/webmin.js');
    
    // Inject 'webstart' command if no argument was given
    if (process.argv.length === 2) {
      process.argv.push('direct_webstart');
    }
    
    module.exports = {
      duniter: {
    
        cliOptions: [
    
          // Webmin options
          { value: '--webmhost <host>', desc: 'Local network interface to connect to (IP)' },
          { value: '--webmport <port>', desc: 'Local network port to connect', parser: parseInt }
        ],
    
        cli: [{
    
          name: 'webstart',
          desc: 'Starts Duniter as a daemon (background task).',
          logs: false,
          onConfiguredExecute: (server, conf, program, params) => co(function*() {
            yield server.checkConfig()
            const daemon = server.getDaemon('direct_webstart', 'webstart')
            yield startDaemon(program, daemon)
          })
        }, {
    
          name: 'webrestart',
          desc: 'Stops Duniter daemon and restart it with its web interface.',
          logs: false,
          onConfiguredExecute: (server, conf, program, params) => co(function*() {
            yield server.checkConfig()
            const daemon = server.getDaemon('direct_webstart', 'webrestart')
            yield stopDaemon(daemon)
            yield startDaemon(program, daemon)
          })
        }, {
          name: 'direct_webstart',
          desc: 'Do a webstart',
          onDatabaseExecute: (server, conf, program, params, startServices, stopServices, stack) => co(function*(){
    
            try {
    
              /****************************************
               * SPECIALISATION
               ***************************************/
    
              const app = express();
              const HOTE = program.webmhost || 'localhost';
              const PORT = program.webmport || 9220;
    
              /**
               * Sur appel de l'URL /abc
               */
              app.use(express.static(path.join(__dirname, '..', 'duniter-ui', 'public')));
    
              app.use(cors());