Executing child_process commands in Node

Hi All,

I’m very new to Resin and Docker so please excuse me if this is a stupid question.

I need to run a USB ftdi relay board from node. The way its working locally (Ubuntu 16.04) is that I execute child_process commands within my node app to a compiled C program. Its not working the same on Resin!

For example I have my C program - relay

I would run it locally from my node app by executing - ./relay param1 param2

If I make a new application with just the compiled C program within it and run the command within my Dockerfile using - CMD ./relay param1 param2 It works just fine.

So my question is how can I run it from within a node app?

Thanks

Got it!

The file needs to be marked as executable in your docker file. Like so:
RUN ["chmod", "+x", "/usr/src/app/relay"]

Glad you got it working.

You can actually remove the RUN step from your Dockerfile and chmod your executable once locally in your source code tree, commit the change and push again. Git preserves file attributes.

Otherwise, if you still prefer a RUN step, you can write it more simply as:

RUN chmod +x /usr/src/app/relay
1 Like