Code Monkey home page Code Monkey logo

Comments (18)

maicoly avatar maicoly commented on July 18, 2024 1

@jimlambie thxs, it's solved!!! wow! thxs. YES, is strange!
Thxs again for support, I will be investigating many more!

from cdn.

jimlambie avatar jimlambie commented on July 18, 2024

Hi @maicoly

Looks like a problem installing from the CLI. I'd try installing directly from NPM instead:

cd ~/boxbeep/cdn_boxbeep
npm init -y
npm i @dadi/cdn

This will give you the latest CDN version, which should be 4.0.0

from cdn.

jimlambie avatar jimlambie commented on July 18, 2024

You'll also need a file to act as the entry point. Add a file called "index.js" with the following content:

require('@dadi/cdn')

Now, running npm start should run the CDN application.

from cdn.

maicoly avatar maicoly commented on July 18, 2024

Hi @jimlambie , thanks for your support
I have this problem when running npm start

0 info it worked if it ends with ok
1 verbose cli [ '/home/maicoly/.nvm/versions/node/v8.9.4/bin/node',
1 verbose cli   '/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli   'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose stack Error: missing script: start
4 verbose stack     at run (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:151:19)
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:61:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:402:5
4 verbose stack     at checkBinReferences_ (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:357:45)
4 verbose stack     at final (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:400:3)
4 verbose stack     at then (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:160:5)
4 verbose stack     at ReadFileContext.<anonymous> (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:$
4 verbose stack     at ReadFileContext.callback (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16)
4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)
5 verbose cwd /home/maicoly/boxbeep/cdn_boxbeep
6 verbose Linux 5.3.0-62-generic
7 verbose argv "/home/maicoly/.nvm/versions/node/v8.9.4/bin/node" "/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm" "start"
8 verbose node v8.9.4
9 verbose npm  v5.6.0
10 error missing script: start
11 verbose exit [ 1, true ]

also when using the node index.js command

fs.js:646
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open './config/config.development.json'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at loadFile (/home/maicoly/boxbeep/cdn_boxbeep/node_modules/convict/lib/convict.js:452:19)
    at /home/maicoly/boxbeep/cdn_boxbeep/node_modules/convict/lib/convict.js:611:24
    at Array.forEach (<anonymous>)
    at Config.loadFile (/home/maicoly/boxbeep/cdn_boxbeep/node_modules/convict/lib/convict.js:609:13)
    at new Config (/home/maicoly/boxbeep/cdn_boxbeep/node_modules/@dadi/cdn/config.js:709:8)
    at Object.<anonymous> (/home/maicoly/boxbeep/cdn_boxbeep/node_modules/@dadi/cdn/config.js:889:18)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)

the version of node I use is 8.9.4
any ideas?

from cdn.

jimlambie avatar jimlambie commented on July 18, 2024

@maicoly I think the defaults for npm start were introduced in a later version. You can add this block into package.json and it will work:

"scripts": {
  "start": "node index.js"
}

As for the next error, yes we will need to add a configuration file:

  1. create new folder config
  2. add file config.development.json

Sample contents for the configuration file are below (and info regarding the settings available at https://docs.dadi.cloud/cdn/3.4#configuration)

{
  "cluster": false,
  "server": {
    "host": "127.0.0.1",
    "port": 8001
  },
  "images": {
    "directory": {
      "enabled": true,
      "path": "./images"
    },
    "s3": {
      "enabled": false,
      "accessKey": "",
      "secretKey": "",
      "bucketName": "",
      "region": ""
    },
    "remote": {
      "enabled": false,
      "path": ""
    }
  },
  "assets": {
    "directory": {
      "enabled": true,
      "path": "./public"
    },
    "s3": {
      "enabled": false,
      "accessKey": "",
      "secretKey": "",
      "bucketName": "",
      "region": ""
    },
    "remote": {
      "enabled": false,
      "path": ""
    }
  },
  "caching": {
    "ttl": 60,
    "directory": {
      "enabled": true,
      "path": "./cache/",
      "autoFlush": true,
      "autoFlushInterval": 120
    },
    "redis": {
      "enabled": false,
      "host": "127.0.0.1",
      "port": 6379
    }
  },
  "logging": {
    "enabled": true,
    "level": "debug",
    "path": "./log",
    "filename": "cdn",
    "extension": "log",
    "accessLog": {
      "enabled": true
    }
  },
  "security": {
    "maxWidth": 10000,
    "maxHeight": 20000
  },
  "auth": {
    "clientId": "1235488",
    "secret": "asd544see68e52"
  },
  "headers": {
    "useGzipCompression": true,
    "cacheControl": {
      "default": "public, max-age=3600",
      "paths": [

      ],
      "mimetypes": [
        { "image/jpeg": "public, max-age=86400" },
        { "text/css": "public, max-age=86400" },
        { "text/javascript": "public, max-age=86400" },
        { "application/javascript": "public, max-age=86400" }
      ]
    }
  },
  "feedback": false
}

from cdn.

maicoly avatar maicoly commented on July 18, 2024

Hi @jimlambie, thanks again for your support
the command node index.js is OK!
maicoly@maicoly-Alienware-Area-51m:~/boxbeep/cdn_boxbeep$ node index.js

⠋ Starting @dadi/cdn...[2020-11-16 11:30:39.552] [LOG]    Process 22756 is listening for incoming requests
[2020-11-16 11:30:39.553] [ERROR]  (node:22756) ExperimentalWarning: The http2 module is an experimental API.
✔ Started DADI CDN
@ http://127.0.0.1:8001

  ┌──────────────────────────────────────────┐
  │ DADI CDN                                 │
  ┌──────────────┬───────────────────────────┐
  │ Protocol     │ http                      │
  │ Version      │ 4.0.0                     │
  │ Node.js      │ 8.9                       │
  │ Environment  │ development               │
  └──────────────┴───────────────────────────┘
  

  ℹ Documentation at https://docs.dadi.cloud
  ℹ <CTRL> + C to shut down

  
   ▓▓▓▓▓  ▓▓▓▓▓▓▓
               ▓▓▓▓
      ▓▓▓▓▓▓▓    ▓▓▓▓
               ▓▓▓▓
          ▓▓▓▓▓▓▓


  © 2020 DADI+ Limited (https://dadi.cloud)
  All rights reserved.

however when I open the url localhost: 8001 I get:

{"statusCode":404,"message":"File not found: /home/maicoly/boxbeep/cdn_boxbeep/public/no-default-configured"}

do i need any other file?

now with npm start (adding the configuration you sent me!)

0 info it worked if it ends with ok
1 verbose cli [ '/home/maicoly/.nvm/versions/node/v8.9.4/bin/node',
1 verbose cli   '/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli   'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose stack Error: missing script: start
4 verbose stack     at run (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:151:19)
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:61:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:402:5
4 verbose stack     at checkBinReferences_ (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:357:45)
4 verbose stack     at final (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:400:3)
4 verbose stack     at then (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:160:5)
4 verbose stack     at ReadFileContext.<anonymous> (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:$
4 verbose stack     at ReadFileContext.callback (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16)
4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)
5 verbose cwd /home/maicoly/boxbeep/cdn_boxbeep
6 verbose Linux 5.3.0-62-generic
7 verbose argv "/home/maicoly/.nvm/versions/node/v8.9.4/bin/node" "/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm" "start"
8 verbose node v8.9.4
9 verbose npm  v5.6.0
10 error missing script: start
11 verbose exit [ 1, true ]

from cdn.

jimlambie avatar jimlambie commented on July 18, 2024

Odd.... can you try npm run start intead?

from cdn.

jimlambie avatar jimlambie commented on July 18, 2024

As for the missing file message - you'll need images in a folder called "images", or whatever is configured (I think the default is just an "images" directory.

Then you can choose one of the files from that folder and try http://localhost:8001/my-file.jpg. The message you got indicates that you requested no file.

A response from http://localhost:8001/hello should also indicate it's running fine...

from cdn.

maicoly avatar maicoly commented on July 18, 2024

the output again is:

0 info it worked if it ends with ok
1 verbose cli [ '/home/maicoly/.nvm/versions/node/v8.9.4/bin/node',
1 verbose cli   '/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli   'run',
1 verbose cli   'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose stack Error: missing script: start
4 verbose stack     at run (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:151:19)
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/lib/run-script.js:61:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:5
4 verbose stack     at /home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:402:5
4 verbose stack     at checkBinReferences_ (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:357:45)
4 verbose stack     at final (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:400:3)
4 verbose stack     at then (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:160:5)
4 verbose stack     at ReadFileContext.<anonymous> (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/read-package-json/read-json.js:$
4 verbose stack     at ReadFileContext.callback (/home/maicoly/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16)
4 verbose stack     at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)
5 verbose cwd /home/maicoly/boxbeep/cdn_boxbeep
6 verbose Linux 5.3.0-62-generic
7 verbose argv "/home/maicoly/.nvm/versions/node/v8.9.4/bin/node" "/home/maicoly/.nvm/versions/node/v8.9.4/bin/npm" "run" "start"
8 verbose node v8.9.4
9 verbose npm  v5.6.0
10 error missing script: start
11 verbose exit [ 1, true ]

package.json:

{
  "scripts": {
    "start": "node index.js"
  },
  "name": "cdn_boxbeep",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@dadi/cdn": "^4.0.0"
  }
}

from cdn.

jimlambie avatar jimlambie commented on July 18, 2024

Ah - you have two "scripts" blocks. Move "start" inside the one further down

from cdn.

maicoly avatar maicoly commented on July 18, 2024

Thxs, @jimlambie; ran without any problem!
I put an image called picture1 PNG format at the time of making the request http://127.0.0.1:8001/picture1 stays loading and does not respond to the request, so I note is that the image extension is needed in the request so that it reads from ../images/picture1.xxx but if not I put it it reads from ../public/picture1
any ideas?

Thxs again for support!

from cdn.

jimlambie avatar jimlambie commented on July 18, 2024

@maicoly pleased it's working for you!

Correct, CDN determines what to do based on the file extension. The configuration blocks for "images" and "assets" control where CDN will look for files that are requested - if the extension isn't a typical image format then it'll assume it's an asset (think CSS, JS, fonts, etc) and use the "assets" block to try to locate it:

e.g.

"assets": {
    "directory": {
      "enabled": true,
      "path": "./public"
    },

from cdn.

maicoly avatar maicoly commented on July 18, 2024

@jimlambie, Maybe I did not understand well, what happens is that in the request it delays responding
image
my directory and files:
image

from cdn.

maicoly avatar maicoly commented on July 18, 2024

maybe, the problem is?:
image

from cdn.

jimlambie avatar jimlambie commented on July 18, 2024

maybe, the problem is?:
image

You can actually ignore this for the time being, it's unrelated

from cdn.

jimlambie avatar jimlambie commented on July 18, 2024

I think perhaps in the case of returning from "assets" it doesn't know what to do with an extension-less file? It's hard to know without debugging properly. Can you add file extensions to make it more obvious?

from cdn.

maicoly avatar maicoly commented on July 18, 2024

Sure, I put the extensions with this result:
image
image

from cdn.

jimlambie avatar jimlambie commented on July 18, 2024

Hmmm... seems strange. Could you change the configuration of the images block (images.directory.path) to the absolute path?

"images": {
    "directory": {
      "enabled": true,
      "path": "/home/maicoly/boxbeep/cdn_boxbeep/images"
    },

from cdn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.