On Thu, Jun 29, 2017 at 10:13 PM, Waldemar Kozaczuk <jwkozac...@gmail.com>
wrote:

> Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
> ---
>  modules/httpserver-html5-cli/Makefile        | 28
> ++++++++++++++++++++++++++++
>  modules/httpserver-html5-cli/httpserver.conf | 20 ++++++++++++++++++++
>  modules/httpserver-html5-cli/module.py       | 24
> ++++++++++++++++++++++++
>  3 files changed, 72 insertions(+)
>  create mode 100644 modules/httpserver-html5-cli/Makefile
>  create mode 100644 modules/httpserver-html5-cli/httpserver.conf
>  create mode 100644 modules/httpserver-html5-cli/module.py
>
> diff --git a/modules/httpserver-html5-cli/Makefile
> b/modules/httpserver-html5-cli/Makefile
> new file mode 100644
> index 0000000..936ae35
> --- /dev/null
> +++ b/modules/httpserver-html5-cli/Makefile
> @@ -0,0 +1,28 @@
> +src = $(shell readlink -f ../..)
> +module-dir = $(src)/modules/httpserver-html5-cli
> +
> +quiet = $(if $V, $1, @echo " $2"; $1)
> +very-quiet = $(if $V, $1, @$1)
> +
> +all: module
> +module: html5-cli
> +
> +html5-cli: osv-html5-terminal/.git
> +       cd $(module-dir) && \
> +       wget https://nodejs.org/dist/v6.11.0/node-v6.11.0-linux-x64.tar.xz
> && \
> +       tar xf node-v6.11.0-linux-x64.tar.xz && rm
> node-v6.11.0-linux-x64.tar.xz && \
>

Since this module basically gets stuff from other repositories, and since
it's not used in the "default" OSv build, perhaps we should put it in the
apps.git repository where most of the applications of this type sit, and
not in modules/?

Also, we already have a "node" module in apps, can we just "require" it
instead of adding more code to get node?
There's a difference - the existing node module fetches node's source and
compiles it - instead of fetching the binary. But if the binary works,
maybe we should switch to that approach and don't bother compiling?
Alternatively, we can add a second package, "node-bin" which fetches node
as binary, and provide()s "node" - so if someone does "build
image=html5-cli" he'll get node compiled from source, but "build
image=node-bin,html5-cli" he'll get node from binary (or vice versa - we
can make the binary the default).



> +       cd osv-html5-terminal && \
> +       PATH=$(module-dir)/node-v6.11.0-linux-x64/bin:$PATH; npm install
> && \
>

I'm not familiar with the node tools - where does this "install" things?


> +       PATH=$(module-dir)/node-v6.11.0-linux-x64/bin:$PATH;
> node_modules/grunt-cli/bin/grunt
> +
> +.PHONY: html5-cli
> +
> +osv-html5-terminal/.git:
> +       cd $(module-dir) && \
> +       git clone https://github.com/wkozaczuk/osv-html5-terminal.git


I guess this is a small project so cloning its entire history is
reasonable, but otherwise using "--depth 1"  (or something of this sort)
could be useful for not bothering to get the full history

>
> +
> +clean:
> +       cd $(module-dir) && rm -rf node-v6.11.0-linux-x64
>

rm -rf $(module-dir)/node-v6.11.0-linux-x64 seems simpler :-)


> +       cd $(module-dir) && rm -rf osv-html5-terminal
> +
> +.SECONDARY:
> diff --git a/modules/httpserver-html5-cli/httpserver.conf
> b/modules/httpserver-html5-cli/httpserver.conf
> new file mode 100644
> index 0000000..47a57b4
> --- /dev/null
> +++ b/modules/httpserver-html5-cli/httpserver.conf
> @@ -0,0 +1,20 @@
> +{
> +  "port": "8000",
> +  "redirects": [
> +    {
> +      "path": "/",
> +      "target_path": "/cli/"
> +    }
> +  ],
> +  "file_mappings": [
> +    {
> +      "path": "/cli",
> +      "file": "/usr/mgmt/cli/index.html",
> +      "exact_match": true
> +    },
> +    {
> +      "path": "/cli",
> +      "directory": "/usr/mgmt/cli"
> +    }
> +  ]
> +}
> diff --git a/modules/httpserver-html5-cli/module.py
> b/modules/httpserver-html5-cli/module.py
> new file mode 100644
> index 0000000..6c7e49f
> --- /dev/null
> +++ b/modules/httpserver-html5-cli/module.py
> @@ -0,0 +1,24 @@
> +import os
> +from osv.modules.api import *
> +from osv.modules.filemap import FileMap
> +from osv.modules import api
> +
> +_module = '${OSV_BASE}/modules/httpserver-html5-cli'
> +
> +usr_files = FileMap()
> +usr_files.add(os.path.join(_module, 'osv-html5-terminal/dist')).
> to('/usr/mgmt/cli')
> +usr_files.add(os.path.join(_module, 'httpserver.conf')).to('/tmp/
> httpserver.conf')
>

Why /tmp?


> +
> +api.require('httpserver-api')
> +
> +# httpserver will run regardless of an explicit command line
> +# passed with "run.py -e".
> +_exe = '/libhttpserver.so'
> +daemon = api.run_on_init(_exe + ' &!')
> +
> +fg = api.run(_exe)
> +
> +fg_ssl = api.run(_exe + ' --ssl')
> +fg_cors = api.run(_exe + ' --access-allow=true')
>
+
> +default = daemon
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osv-dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to