Posts Tagged ‘node.js’

The great open source mashup on IBM i

To the outside world and perhaps 80% of the established IBM i community running open source applications on the IBM i operating system is irrelevant.  This is a crime of monumental proportions in that folks are standing up *NIX and Windows servers while they let their IBM i’s languish with “legacy” applications.  How sad for them. They are missing out on the benefits of leveraging those legacy apps with open source frameworks that could make their shops more productive, scalable and secure.

Node is getting the latest buzz on the web and in the small but active open source community on IBM i.  I gotta admit that getting that first node app up was my goal (be first!) when it was first announced but my younger alter-ego, Aaron Bartell beat me to it (as usual).  But getting node.js stood up as a server is only the first step.  Getting a “hello world” app working is perhaps the second but the real fun is taking a few existing technologies and putting together a mashup that leverages old with new.  You IBM i folks have a boatload of RPG apps, how the heck would you hook them up with node.js?

socket.io and express.js being TCP/HTTP friendly make that a good place to start!  The IBM i is a rock solid HTTP server platform.  There are plenty of open source technologies that leverage HTTP on IBM i so using HTTP is a logical place to start.  How could we link things up so that node.js serves up apps that can communicate with and use other HTTP technologies?  Well, I threw together an RPG app that uses an HTTP POST to post data to the chat application example.  Check out a quick and dirty example I put together on my Github repo here. It isn’t as robust as I want it to be but I am just getting started here (and wanted to do more than just ‘Hello World’!)

Just think of the possibilities!  HTTP is the perfect way to mash up all things IBM i.  More to come!

Comments Off on The great open source mashup on IBM i

Stumbling startup with node.js on IBM i

My 7.2 upgrade was done specifically to get going with an “officially” supported version of node.js.  Installing 5733OPS is a no brainer (either RSTLICPGM or just using the option to install a licensed program in the LICPGM menu will work).  Node worked great.  Already creating much mayhem with socket.io, express.js, and a bunch of other stuff I will eventually break.  The problem I had is that I could only do this stuff when I was in the Node/bin folder.  Otherwise I would see:

node -v
exec(): 0509-036 Cannot load program node because of the following errors:
0509-150   Dependent module libstdc++.a(libstdc++.so.6) could not be loaded.
0509-022 Cannot load module libstdc++.a(libstdc++.so.6).
0509-026 System error: A file or directory in the path name does not exist.

What?   I am only a noob when it comes to *NIX environments and I know there are a bunch of moving parts that need to be correctly aligned.  I thought my PATH was the only thing I needed to look at but I was missing something essential: The LIBPATH environment variable.  Many executables share functionality so the “helper” objects need to be in the PATH as well so they can be found (like service programs or DLL’s) so the LIBPATH needs to be set as well.  My “Brogrammer” in the Open Source space, Aaron Bartell, turned me on to that fact and he proposes a couple of solutions.  You could just manually set the PATH and LIBPATH:

[Depending on the shell you use you can either do it in one step like this]

export PATH=/QOpenSys/QIBM/ProdData/Node/bin:$PATH
export LIBPATH=/QOpenSys/QIBM/ProdData/Node/bin:$LIBPATH

[or your shell may require that you do it in two steps like this]

PATH=/QOpenSys/QIBM/ProdData/Node/bin:$PATH
export PATH
LIBPATH=/QOpenSys/QIBM/ProdData/Node/bin:$LIBPATH
export LIBPATH

Or you could create a script and just run it when needed.  Here are some screen shots that show the problem and solutions:

node_error

So the problem occurs in #1 above even though I have the node/bin folder on my path (#2).  If I check the LIBPATH environment variable, it is empty so I append the path to the shared library to the LIBPATH (which just happens to be the same as the node/bin folder).  Adding the path and exporting it makes it available to my environment so now when I run node – v I get the version listed rather than an error.  Nice!  Aaron pointed me here to find this info and recommended that I post questions here so that others might benefit.  Agreed!  But I’ll probably also post here since I tend to forget where I posted solutions to my issues.

The script to do this is simple as well.  You should have a folder in your IBM i “home” folder under your IBM i user name.  Mine would be /home/PETE/  You could either use this command on IBM i:

EDTF ‘node_env.sh’   (you can call the script whatever you want) :

edtf_node_env

If you want to up your *NIX geek cred, you could use vi in SSH (or call qp2term):

vi /home/PETE/node_env.sh

vi_node_env

However you get there!  Then when you are in the console you can just execute the script:

node_script_fix

So, all is well.  Just remember to execute the node_env.sh script, OR, if you are going to launch a node server instance using CL, I usually create a script and then just execute the script in the CL program so you don’t have to have multiple entries to set the environment.  Just do your heavy lifting in the script, let your CL do the easy part.

So, that’s it!  There is probably more detail here than most folks need but for folks who are new to open source on IBM i, a little extra instruction can fill in a lot of blanks.

 

Comments Off on Stumbling startup with node.js on IBM i

WP Login