HEADS-project / training

Training material to get started with the HEADS technologies
10 stars 16 forks source link

How to specify node name when running grunt #33

Closed kehusa closed 9 years ago

kehusa commented 9 years ago

Hi,

How am I able to specify the node name of current javascript node when running grunt? Is it possible to load deployment units from local machine when running kevoreejs?

Knut Eilif

maxleiko commented 9 years ago

Hello,

Yes you can specify the node name using the command-line argument --node or by modifying your Gruntfile. I have made some doc for grunt-kevoree that can help https://github.com/kevoree/kevoree-js/blob/master/tools/grunt-kevoree/README.md

Yes you can also load local projects by using the latest version of grunt-kevoree. The process is also described in the doc.

Feel free to ask for more info :)

brice-morin commented 9 years ago

@maxleiko can you create an issue on HEADS-project/forum that gather all the links, hints, etc for Kevoree? As Franck started for ThingML

kehusa commented 9 years ago

My gruntfile.js looks like this: module.exports = function (grunt) {

grunt.initConfig({

    // retrieve your project package.json
    pkg: grunt.file.readJSON('package.json'),

    // creates kevlib.json which represents your project Kevoree model
    // by parsing your pkg.main entry point
    kevoree_genmodel: {
        main: {
            options: {
                quiet: false,
                verbose: true
            }
        }
    },

    // pushes your model on http://registry.kevoree.org
    kevoree_registry: { src: 'kevlib.json' }
});

grunt.loadNpmTasks('grunt-kevoree');
grunt.loadNpmTasks('grunt-kevoree-genmodel');
grunt.loadNpmTasks('grunt-kevoree-registry');

grunt.registerTask('default', 'build');
grunt.registerTask('build', ['kevoree_genmodel']);
grunt.registerTask('publish', 'kevoree_registry');
grunt.registerTask('kev', ['kevoree']);

};

Cant find the kevoree: task. Do I need to recreate the project using yeoman?

2015-02-03 13:39 GMT+01:00 Brice Morin notifications@github.com:

@maxleiko https://github.com/maxleiko can you create an issue on HEADS-project/forum that gather all the links, hints, etc for Kevoree? As Franck started for ThingML

— Reply to this email directly or view it on GitHub https://github.com/HEADS-project/training/issues/33#issuecomment-72643554 .

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

kehusa commented 9 years ago

Ok, there were some missing commas in:

grunt.initConfig({ // all those options are optional because they are the default behavior kevoree: { options: { runtime: 'latest', node: 'node0', kevscript: 'kevs/main.kevs', modulesPath: '.deploy_units' // comma missing mergeLocalLibraries: [] // comma missing logLevel: 'debug' } } });

2015-02-03 14:07 GMT+01:00 Knut Eilif Husa knut.eilif.husa@tellu.no:

My gruntfile.js looks like this: module.exports = function (grunt) {

grunt.initConfig({

    // retrieve your project package.json
    pkg: grunt.file.readJSON('package.json'),

    // creates kevlib.json which represents your project Kevoree model
    // by parsing your pkg.main entry point
    kevoree_genmodel: {
        main: {
            options: {
                quiet: false,
                verbose: true
            }
        }
    },

    // pushes your model on http://registry.kevoree.org
    kevoree_registry: { src: 'kevlib.json' }
});

grunt.loadNpmTasks('grunt-kevoree');
grunt.loadNpmTasks('grunt-kevoree-genmodel');
grunt.loadNpmTasks('grunt-kevoree-registry');

grunt.registerTask('default', 'build');
grunt.registerTask('build', ['kevoree_genmodel']);
grunt.registerTask('publish', 'kevoree_registry');
grunt.registerTask('kev', ['kevoree']);

};

Cant find the kevoree: task. Do I need to recreate the project using yeoman?

2015-02-03 13:39 GMT+01:00 Brice Morin notifications@github.com:

@maxleiko https://github.com/maxleiko can you create an issue on HEADS-project/forum that gather all the links, hints, etc for Kevoree? As Franck started for ThingML

— Reply to this email directly or view it on GitHub https://github.com/HEADS-project/training/issues/33#issuecomment-72643554 .

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

kehusa commented 9 years ago

Next issue:

Running "kevoree_genmodel:main" (kevoree_genmodel) task Package: no.tellu TypeDefinition: ChatServer Version: 0.1.0 DeployUnit: kevoree-comp-chatserver Input port(s): [ input ] Output port(s): [ chatClients ]

Model generation done Model 'kevlib.json' saved at kevlib.json

Done, without errors. kevoree-comp-chatserver@0.1.0 .deploy_units\chatserver\node_modules\kevoree-comp -chatserver └── kevoree-entities@7.0.1 (pseudoclass@1.0.2, kevoree-commons@2.1.0, kevoree-li brary@5.0.4, kevoree-kevscript@2.1.5) 14:17:21 DEBUG AddDeployUnit /packages[no]/packages[tellu]/deployUnits[hash code=,name=kevoree-comp-chatserver,version=0.1.0] 14:17:21 DEBUG AddInstance broker /packages[org]/packages[kevoree]/packag es[library]/typeDefinitions[name=WSMsgBroker,version=1.0.2] 14:17:21 DEBUG AddInstance group /packages[org]/packages[kevoree]/package s[library]/typeDefinitions[name=WSGroup,version=5.2.2] 14:17:21 DEBUG AddInstance server /packages[no]/packages[tellu]/typeDefin itions[name=ChatServer,version=0.1.0] 14:17:21 DEBUG AddInstance chan /packages[org]/packages[kevoree]/packages [library]/typeDefinitions[name=WSChan,version=5.2.3-SNAPSHOT] 14:17:21 DEBUG AddBinding output /nodes[chatserver]/components[server]/r equired[chatClients] <-> /hubs[chan] 14:17:21 DEBUG UpdateDictiona. chan.host = localhost 14:17:21 DEBUG UpdateDictiona. chatserver.logLevel = DEBUG 14:17:21 DEBUG UpdateDictiona. broker.port = 9050 14:17:21 DEBUG UpdateDictiona. group.master = chatserver 14:17:21 DEBUG UpdateDictiona. chan.port = 9050 14:17:21 INFO WSGroup "group" listen on 9000 14:17:21 DEBUG StartInstance /groups[group] 14:17:21 ALL KevoreeLogger Set logLevel= debug 14:17:21 DEBUG StartInstance /nodes[chatserver] 14:17:21 DEBUG ChatServer START 14:17:21 DEBUG StartInstance /nodes[chatserver]/components[server] 14:17:21 INFO WSMsgBroker "broker" listen on 0.0.0.0:9050 14:17:21 DEBUG StartInstance /nodes[chatserver]/components[broker] 14:17:21 DEBUG StartInstance /hubs[chan] 14:17:21 DEBUG KevoreeCore Model deployed successfully: 19 adaptations (5 762ms)

Bootstrap model deployed successfully Fatal error: listen EACCES

Any idea?

2015-02-03 14:16 GMT+01:00 Knut Eilif Husa knut.eilif.husa@tellu.no:

Ok, there were some missing commas in:

grunt.initConfig({ // all those options are optional because they are the default behavior kevoree: { options: { runtime: 'latest', node: 'node0', kevscript: 'kevs/main.kevs', modulesPath: '.deploy_units' // comma missing mergeLocalLibraries: [] // comma missing logLevel: 'debug' } } });

2015-02-03 14:07 GMT+01:00 Knut Eilif Husa knut.eilif.husa@tellu.no:

My gruntfile.js looks like this: module.exports = function (grunt) {

grunt.initConfig({

    // retrieve your project package.json
    pkg: grunt.file.readJSON('package.json'),

    // creates kevlib.json which represents your project Kevoree model
    // by parsing your pkg.main entry point
    kevoree_genmodel: {
        main: {
            options: {
                quiet: false,
                verbose: true
            }
        }
    },

    // pushes your model on http://registry.kevoree.org
    kevoree_registry: { src: 'kevlib.json' }
});

grunt.loadNpmTasks('grunt-kevoree');
grunt.loadNpmTasks('grunt-kevoree-genmodel');
grunt.loadNpmTasks('grunt-kevoree-registry');

grunt.registerTask('default', 'build');
grunt.registerTask('build', ['kevoree_genmodel']);
grunt.registerTask('publish', 'kevoree_registry');
grunt.registerTask('kev', ['kevoree']);

};

Cant find the kevoree: task. Do I need to recreate the project using yeoman?

2015-02-03 13:39 GMT+01:00 Brice Morin notifications@github.com:

@maxleiko https://github.com/maxleiko can you create an issue on HEADS-project/forum that gather all the links, hints, etc for Kevoree? As Franck started for ThingML

— Reply to this email directly or view it on GitHub https://github.com/HEADS-project/training/issues/33#issuecomment-72643554 .

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

maxleiko commented 9 years ago

Actually you don't need to explicitly declare the kevoree task in your Gruntfile because every options have a default value. So if you do not say anything about the kevoree task, it will use the defaults.

Sorry for the commas, I'll fix this.

maxleiko commented 9 years ago

Oops, this is not I/O related. This is an occupied port error. You might have already something listening on 9000 or 9050 ?

kehusa commented 9 years ago

Is it a port conflict between Grunt and WSGroup? see https://github.com/yeoman/yo/issues/95

2015-02-03 14:20 GMT+01:00 Maxime Tricoire notifications@github.com:

This is an error of I/O concerning write rights.

— Reply to this email directly or view it on GitHub https://github.com/HEADS-project/training/issues/33#issuecomment-72648619 .

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

maxleiko commented 9 years ago

I see that your example is a chat client/server, I suspect that you have multiple nodes. If it is true that you have multiple nodes connected to the same WSGroup, then you need to set a master for one of them otherwise it will try to start a WS server on each node, and the default port for this action is 9000.
Isn't it the problem ?

Your kevscript needs something like:

set myGrp.master = "someNode"
kehusa commented 9 years ago

I was trying: //sample of KevScript configuration

add chatserver : JavascriptNode

// provide a network way to connect to those nodes network chatserver.ip.lo 127.0.0.1

add group : WSGroup set group.master = 'chatserver' attach chatserver group

// create and add your HelloWorld component (named "myComp") in "node0" add chatserver.server : no.tellu.ChatServer

add chatserver.broker : WSMsgBroker

// define on which port the broker will start set chatserver.broker.port = '9050'

// add a WSChan to transmit the messages between the Ticker and the ConsolePrinter add chan : WSChan/5.2.3-SNAPSHOT

// give the host:port of the broker to the chan set chan.host = "localhost" set chan.port = "9050"

// bind the printer to the chan bind chatserver.server.chatClients chan

Had to add:

set group.port = '9010'

Then it worked.

2015-02-03 14:44 GMT+01:00 Maxime Tricoire notifications@github.com:

I see that your example is a chat client, I suspect that you have multiple node. If it is true that you have multiple nodes connected to the same WSGroup, then you need to set a master for one of them otherwise it will try to start a WS server on each node, and the default port for this action is 9000.

Isn't it the problem ?

Your kevscript needs something like:

set myGrp.master = "someNode"

— Reply to this email directly or view it on GitHub https://github.com/HEADS-project/training/issues/33#issuecomment-72652101 .

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

maxleiko commented 9 years ago

Then you have another "thing" that is using your 9000 port, obviously :)

kehusa commented 9 years ago

When I stop the node and try localhost:9000 in my browser I get no answer, so I don't think I have anything else running on port 9000.

See this post: http://stackoverflow.com/questions/20170746/how-to-change-auto-open-page-by-livereload-in-yeoman Could it be a collision between default port of WSGroup and Grunt's livereload that also defaults to port 9000?

2015-02-03 14:48 GMT+01:00 Maxime Tricoire notifications@github.com:

Then you have another "thing" that is using your 9000 port, obviously :)

— Reply to this email directly or view it on GitHub https://github.com/HEADS-project/training/issues/33#issuecomment-72652692 .

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

maxleiko commented 9 years ago

Kevoree do not use livereload, it only uses what's loaded, which are:

grunt.loadNpmTasks('grunt-kevoree');
grunt.loadNpmTasks('grunt-kevoree-genmodel');
grunt.loadNpmTasks('grunt-kevoree-registry');

and none of those task start a server by default unless the grunt-kevoree one because it starts a kevoree js runtime which, by default, contains a WSGroup, which by default start a WS server on port 9000.
Have you checked your daemons or background processes ? Any chances a killall node solves the issue ?

kehusa commented 9 years ago

So what you are saying is that when I specify another WSGroup in my kevs (I added one called group), this will conflict with the default one that is started?

2015-02-03 14:59 GMT+01:00 Maxime Tricoire notifications@github.com:

Kevoree do not use livereload, it only uses what's loaded, which are:

grunt.loadNpmTasks('grunt-kevoree'); grunt.loadNpmTasks('grunt-kevoree-genmodel'); grunt.loadNpmTasks('grunt-kevoree-registry');

and none of those task start a server by default unless the grunt-kevoree one because it starts a kevoree js runtime which, by default, contains a WSGroup, which by default start a WS server on port 9000.

Have you checked your daemons or background processes ? Any chances a killall node solves the issue ?

— Reply to this email directly or view it on GitHub https://github.com/HEADS-project/training/issues/33#issuecomment-72654229 .

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

maxleiko commented 9 years ago

If you do not specify the port of the new group, yes.
You need to manage your ports manually (and explicitly) in your KevScript when you need more that one group, because every WSGroup uses by default 9000

kehusa commented 9 years ago

Ok, almost understands this now :-) But how come that I was able to run tutorial 5. without this problem. There I also added a WSGroup and didn't have this problem.

2015-02-03 15:14 GMT+01:00 Maxime Tricoire notifications@github.com:

If you do not specify the port of the new group, yes.

You need to manage your ports manually (and explicitly) in your KevScript when you need more that one group, because every WSGroup uses by default 9000

— Reply to this email directly or view it on GitHub https://github.com/HEADS-project/training/issues/33#issuecomment-72656608 .

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

maxleiko commented 9 years ago

When a WSGroup starts, it reads the dictionary attributes to find if it has to start as a server or just a client. So if you specified, for instance:

add node : JavascriptNode
add group: WSGroup

attach node group

set group.master = 'node'

Then it will start as a server, using 0.0.0.0:9000 by default.
Now, if you want to add another group to the equation, for instance:

add node : JavascriptNode
add group: WSGroup
add secondGroup: WSGroup

attach node group
attach node secondGroup

set group.master = 'node'
set secondGroup.master = 'secondGroup'

Then, you have to change the port for that second group, otherwise you will get a conflict.

// set the port of the second group to prevent conflicts
set secondGroup.port = '9042'

When you have multiple nodes, the problem remains the same.
There is no problem in tutorial 5 because a master is set.

Here, there is also no problem. Your KevScript is fine. However, you might have something conflicting with 9000. It is possible that something within grunt had let node in a bad state when the error occured the first time, resulting in a child process still running on your machine. Maybe you should try to scan if your 9000 port is still open using netstat or nc.
If it is the case, I'll try to make kevoree fail on purpose to reproduce the bug and try to locate it. If it is not the case, then back to square one.

kehusa commented 9 years ago

You were right, I had a java process running as a background process that had opened port 9000.

Anyway, I learned a lot, thx.

2015-02-03 15:35 GMT+01:00 Maxime Tricoire notifications@github.com:

When a WSGroup starts, it reads the dictionary attributes to find if it has to start as a server or just a client. So if you specified, for instance:

add node : JavascriptNode add group: WSGroup

attach node group

set group.master = 'node'

Then it will start as a server, using 0.0.0.0:9000 http://0.0.0.0:9000 by default.

Now, if you want to add another group to the equation, for instance:

add node : JavascriptNode add group: WSGroup add secondGroup: WSGroup

attach node group attach node secondGroup

set group.master = 'node' set secondGroup.master = 'secondGroup'

Then, you have to change the port for that second group, otherwise you will get a conflict.

// set the port of the second group to prevent conflicts set secondGroup.port = '9042'

When you have multiple nodes, the problem remains the same.

There is no problem in tutorial 5 because a master is set.

Here, there is also no problem. Your KevScript is fine. However, you might have something conflicting with 9000. It is possible that something within grunt had let node in a bad state when the error occured the first time, resulting in a child process still running on your machine. Maybe you should try to scan if your 9000 port is still open using netstat or nc.

If it is the case, I'll try to make kevoree fail on purpose to reproduce the bug and try to locate it. If it is not the case, then back to square one.

— Reply to this email directly or view it on GitHub https://github.com/HEADS-project/training/issues/33#issuecomment-72660130 .

Knut Eilif Husa

Tellu AS Email: knut.eilif.husa@tellu.no Mob: (+47) 452 49496 Web: www.tellu.no

maxleiko commented 9 years ago

:+1: