deploy1 6 rokov pred
rodič
commit
2babbd9e11
8 zmenil súbory, kde vykonal 376 pridanie a 0 odobranie
  1. 0 0
      CHANGELOG
  2. 35 0
      CloudronManifest.json
  3. 0 0
      DESCRIPTION.md
  4. 53 0
      Dockerfile
  5. 0 0
      VERSION
  6. 230 0
      index.js
  7. 26 0
      package.json
  8. 32 0
      start.sh

+ 0 - 0
CHANGELOG


+ 35 - 0
CloudronManifest.json

@@ -0,0 +1,35 @@
+{
+    "id": "dk.tum.asocketserver",
+    "title": "datserver app",
+    "author": "boot",
+    "description": "file://DESCRIPTION.md",
+    "changelog": "./CHANGELOG",
+    "tagline": "asocketserver",
+    "version": "1.0.0",
+    "healthCheckPath": "/healthcheck",
+    "httpPort": 3004,
+    "addons": {
+        "ldap": {},
+        "localstorage": {}
+    },
+    "tcpPorts": {
+        "S_PORT": {
+            "title": "S Port",
+            "description": "S Port.",
+            "defaultValue": 12099
+        },
+        "B_PORT": {
+            "title": "B Port",
+            "description": "B Port.",
+            "defaultValue": 4282
+        }
+    },
+    "manifestVersion": 1,
+    "website": "https://ogi.dk",
+    "contactEmail": "boot@ogi.dk",
+    "icon": "logo.png",
+    "tags": [
+        "datserver"
+    ],
+    "mediaLinks": []
+}

+ 0 - 0
DESCRIPTION.md


+ 53 - 0
Dockerfile

@@ -0,0 +1,53 @@
+FROM cloudron/base:1.0.0@sha256:147a648a068a2e746644746bbfb42eb7a50d682437cead3c67c933c546357617
+
+RUN mkdir -p /app/code
+WORKDIR /app/code
+
+#RUN ln /
+
+RUN apt-get update -y 
+
+#RUN npm install -g hypercored
+#RUN npm install -g dat
+#RUN npm install -g pm2  
+
+#WORKDIR /app
+#RUN npm install https://git.tum.dk/tum.dk/aserver/archive/v0.0.4.tar.gz
+
+
+
+COPY package.json /app/code/
+
+RUN npm install
+
+COPY index.js /app/code/
+COPY views /app/code/views
+
+RUN ln -s /app/code/node_modules /app/node_modules
+
+#RUN curl -L https://git.tum.dk/tum.dk/aserver/archive/v0.0.1.tar.gz | tar -vxz --strip-components 1 -f -
+
+#RUN npm install 
+
+
+# node_modules have to be in data to allow plugins to be installable at runtime
+#RUN cd /app/code/src && npm install && \
+#    ln -s /app/data/node_modules /app/code/node_modules
+
+# https://github.com/ether/etherpad-lite/issues/2683
+#RUN touch src/.ep_initialized
+
+#COPY settings.json.template /app/code/settings.json.template
+#RUN mv src/static/custom src/static/custom_templates && ln -s /app/data/custom src/static/custom
+
+# make these writable (var is used for cache)
+# node_modules contains plugins, the etherpad code is only linked into /app/data/node_modules
+#RUN ln -s /app/data/APIKEY.txt /app/code/APIKEY.txt && \
+#    ln -s /app/data/SESSIONKEY.txt /app/code/SESSIONKEY.txt && \
+#    rm -rf /app/code/var && ln -s /run/etherpad-lite/var /app/code/var && \
+#    rm -rf /home/cloudron/.npm && ln -s /tmp/.npm /home/cloudron/.npm && \
+#    rm -rf /root/.npm && ln -s /tmp/.npm /root/.npm
+
+COPY start.sh /app/code/
+
+CMD [ "/app/code/start.sh" ]

+ 0 - 0
VERSION


+ 230 - 0
index.js

@@ -0,0 +1,230 @@
+/*
+servera index file
+*/
+var argvs = require("optimist").argv;
+var path = require("path");
+var fs = require("fs-extra");
+var _ = require("lodash");
+
+var options = {
+    pwd: argvs.datadir || process.env.PWD,
+    dirname: argvs.dirname || __dirname,
+    port: argvs.port || 3004,
+    verbose: argvs.verbose || false,
+    debug: argvs.debug || false,
+    origin: argvs.origin || process.env.APP_DOMAIN || (Math.floor(Math.random() * 0xffffffff)),
+}
+options.configfile = argvs.configfile || path.join(options.pwd, "/servera.config.json")
+try {
+    options = Object.assign(require(options.configfile), options);
+} catch (e) {
+    !!options.verbose ? console.log("no file:", options.configfile) : null;
+    options.noconfigfile = true;
+}
+
+!!options.verbose ? console.log("using config:", options) : null;
+
+if (argvs.help) {
+    console.log("--datadir", options.pwd);
+    console.log("--dirname", options.dirname);
+    console.log("--port", options.port);
+    console.log("--verbose", options.verbose);
+    console.log("--debug", options.debug);
+    console.log("--origin", options.origin);
+    console.log("--configfile", options.noconfigfile ? "not found" : "", options.configfile);
+    console.log("--repl", argvs.repl);
+    console.log("--client", argvs.client);
+    console.log("--init");
+    process.exit()
+}
+if (argvs.init) {
+    console.log("INIT");
+    var fs = require("graceful-fs");
+    if (!fs.existsSync(path.join(options.pwd, "/views"))) {
+        fs.mkdirSync(path.join(options.pwd, "/views"))
+        fs.copyFileSync(path.join(options.dirname, "/views/index.html"), path.join(options.pwd, "/views/index.html"))
+    }
+    console.log(fs);
+    process.exit();
+}
+
+
+var server = require("aserver")(options);
+server = require("aserver-extend")(server);
+server = require("aserver-tools")(server);
+server.rooten = {};
+
+server.options = options;
+
+server.add_action("NOPE server.init.first", function(app) {
+    app.use(server.ratelimit({
+        max: 120,
+        windowMs: 120 * 1000,
+        delayAfter: 100
+    }));
+}, 7)
+
+server.add_action("server.init.first", function(app) {
+    app.use(function(req, res, next) {
+        console.log(req.method, req.url);
+        next();
+    });
+}, 7)
+
+var tool = {};
+/*tool.template = function template(str, obj) {
+    return str.replace(/\{\{([a-zA-Z0-9]*)\}\}/gi, function(a, m) {
+        return obj[m] ? obj[m] : m
+    })
+}*/
+
+tool._ = require("lodash");
+tool.util = require("util");
+//tool = require("./clienta")(tool);
+//tool = require("./dist/lib_src")(tool, false)
+server.tool = tool
+
+
+//require("./serverstd")(server);
+//require("./plugins/buckets/bucketstd")(server);
+
+
+
+try {
+    var ff = fs.readdirSync(path.join(options.pwd, "./node_modules")).map(function(file) {
+        console.log("FIII", file);
+        return {
+            file: file,
+            isa: fs.readdirSync(path.join(options.pwd, "./node_modules/", file)).filter(function(filea) {
+                return filea === "electra.json"
+            })
+        }
+    }).filter(function(f) {
+        return f.isa.length > 0
+    })
+    ff.map(function(ffa) {
+        console.log("**** loading module: ", ffa.file)
+        require(ffa.file)(server);
+    })
+} catch (e) {
+    console.log("ERROR:", e)
+}
+
+
+
+
+server.add_action("server.init", function(app) {
+
+    /*   app.get("/plugins/:plugin/:file", function(req, res, next) {
+        res.render(path.join(options.dirname, "./plugins/", req.params.plugin, req.params.file + ".html"), Object.assign({
+            req: req,
+            tool: tool,
+        }, tool));
+    })
+
+
+    app.get("/", function(req, res, next) {
+        res.render("index.html", Object.assign({
+            req: req,
+            tool: tool,
+        }, tool));
+    })
+
+    app.get("/tester", function(req, res, next) {
+        res.render("test.html", Object.assign({
+            req: req,
+            tool: tool,
+        }, tool));
+    })
+*/
+
+    app.get("/", function(req, res, next) {
+
+        res.send({
+            "status": "ok"
+        })
+
+    })
+
+
+
+
+
+});
+
+server.add_action("request.init", function(req, res, next) {
+    console.log("req.url", req.ip, req.url, req.parts)
+});
+
+
+try {
+    require(path.join(options.pwd, "/server.js"))(server);
+} catch (e) {
+    !!options.verbose ? console.log("no file:", path.join(options.pwd, "/server.js"), e) : null;
+}
+
+if (argvs.repl) {
+    var repl = require("repl");
+    var cmdline = repl.start({
+        prompt: '> '
+    });
+    cmdline.context.server = server;
+    cmdline.context.options = options;
+    Object.defineProperty(cmdline.context, 'rooten', {
+        enumerable: true,
+        get: function get() {
+            return server.rooten;
+        }
+    });
+
+    function bb(arg) {
+        this.name = arg
+    }
+    bb.prototype.test = function() {
+        return this.name;
+    }
+    cmdline.context.bb = bb;
+    cmdline.context.alle =
+        cmdline.context.app = server;
+    cmdline.context._ = _;
+}
+
+
+if (argvs.client) {
+    console.log("client code to come");
+} else {
+    server.startit();
+}
+
+//
+
+
+function sttttttt() {
+    AWS = require("aws-sdk");
+    app.aws = AWS;
+    AWS.config.update({
+        region: "eu-west-1",
+        credentials: new AWS.CognitoIdentityCredentials({
+            IdentityPoolId: "eu-west-1:5343270a-03fd-4856-ad07-25f1e2c78246"
+        })
+    });
+    var s3 = new AWS.S3({
+        apiVersion: '2006-03-01',
+        params: {
+            Bucket: "a.tum.dk"
+        }
+    });
+    app.s3 = s3;
+    app.s3.upload({
+        Key: "data/test.json",
+        Body: "{}",
+        ContentType: "application/json",
+        "headers": {
+            "Access-Control-Allow-Origin": "*"
+        },
+        ACL: 'public-read'
+    }, function(err, data) {
+        console.log("err", err, data);
+    })
+
+}

+ 26 - 0
package.json

@@ -0,0 +1,26 @@
+{
+    "name": "asocketserver",
+    "version": "1.0.0",
+    "description": "",
+    "main": "index.js",
+    "scripts": {
+        "test": "echo \"Error: no test specified\" && exit 1"
+    },
+    "repository": {
+        "type": "git",
+        "url": "ssh://git@git.tum.dk/tum.dk/asocketserver.git"
+    },
+    "author": "",
+    "license": "ISC",
+    "dependencies": {
+        "aserver": "https://git.tum.dk/tum.dk/aserver/archive/v0.0.14.tar.gz",
+        "aserver-extend": "https://git.tum.dk/tum.dk/aserver-extend/archive/v0.0.4.tar.gz",
+        "aserver-tools": "https://git.tum.dk/tum.dk/aserver-tools/archive/v0.0.2.tar.gz",
+        "diff": "^3.5.0",
+        "fs-extra": "^7.0.1",
+        "lodash": "^4.17.11",
+        "optimist": "^0.6.1",
+        "path": "^0.12.7",
+        "request": "^2.88.0"
+    }
+}

+ 32 - 0
start.sh

@@ -0,0 +1,32 @@
+#!/bin/bash
+
+echo "START"
+
+
+#if [[ ! -f /app/data/feeds ]]; then
+#	echo "dat://0b8c56d3dcf9e3eae168a883cc131e1e6a1780172ff3f53f0c60abcf4cac2436" > /app/data/feeds
+#fi
+
+cd /app/data
+
+ 
+ 
+ 
+
+
+
+node /app/code/index.js --verbose
+
+#HTTTP  ALL 
+
+
+
+
+
+
+
+
+
+
+
+