IBM / ibmi-oss-issues

Important resources for anyone interested in open source on IBM i
Creative Commons Zero v1.0 Universal
13 stars 0 forks source link

Auto Start Node-Red? #4

Closed jeffg324 closed 3 years ago

jeffg324 commented 3 years ago

Hi, I set up the Node-Red Dashboard example (Thank you Matt!) and I'm sure I'm missing something easy....... how do you auto start node-red without signing into SSH? I would like to have it start anytime the system restarts with my intervention, maybe submit a job with STRQSH?

thebeardedgeek commented 3 years ago

@jeffg324 there are multiple ways to do it from QSH but this one I believe is very straight forward.

  1. Create this script somewhere in the IFS on your system (you will need to reference it later) https://github.com/ThePrez/IBMiOSS-utils/blob/master/sbmjob.sh

  2. Call it like this: QSH CMD('/oss_scripts/sbmjob.sh node-red')

NOTE: You can change which subsystem node (or whatever job you want to launch) starts under by modifying the script. I changed my to QPGMR. image

  1. Add it to your startup script or wherever you want to call it from (here is one way you could call it) SBMJOB CMD(QSH CMD('/oss_scripts/sbmjob.sh node-red'))

Things to keep in mind:

  1. Make sure the subsystem gets started where you elect to send the job
  2. The user that is executing the script must have their profile path setup correctly for open source and node otherwise I believe you have to full qualify the path to node-red (i.e. /QOpenSys/pkgs/lib/nodejs12/bin/node-red) https://ibmi-oss-docs.readthedocs.io/en/latest/yum/README.html#must-know-usage-notes-read-this-after-you-install image NOTE: My node-red instance runs in Node.js 12

I hope this helps. Let me know if you have other questions.

jeffg324 commented 3 years ago

That's great, I was on the right path, thanks Matt!

thebeardedgeek commented 3 years ago

You're welcome

ThePrez commented 3 years ago

Thanks, @thebeardedgeek !!

If you get into starting/managing multiple services, you might find my Service Commander tool handy as well.

jeffg324 commented 3 years ago

That's a slick tool, thanks @ThePrez !

I noticed you have Kafka in the video, I'm interested in trying that as well, any tips on where to get install and setup help?

ThePrez commented 3 years ago

I do! https://github.com/IBM/ibmi-oss-examples/blob/master/camel/dtaq_to_kafka/KAFKA_DEPLOY.md

And you can get some free hands-on at https://www.zend.com/ibm-i-training-exercises

Feel free to come back with any questions remaining that you might have

ThePrez commented 3 years ago

Also, FWIW, I hope to publish this feature next week: https://github.com/ThePrez/ServiceCommander-IBMi/issues/25

It should allow you to define services as autostart and then change the *SC TCP server to autostart (at least that's the vision. I am a newb at that aspect of things)

thebeardedgeek commented 3 years ago

@jeffg324 Were you ever able to get this working?

I was playing around with this today and came up with another way to do it: ===> SBMJOB CMD(QSH CMD('/oss_scripts/start-node.sh')) JOB(NODERED) JOBQ(QPGMR) USER(MATTDEV)

Contents of start-node.sh:

PATH=/QOpenSys/pkgs/lib/nodejs12/bin:/QOpenSys/pkgs/bin:$PATH
export PATH
echo $PATH

node-red
jeffg324 commented 3 years ago

@thebeardedgeek Thanks for following up on this. I was not able to get it to work and after spending a few hours on it I got distracted by 'work' and haven't been back. ;-)

I put your script in with a small change to use nodejs14 and the sbmjob worked like a charm! Thanks again, looking forward to customizing some dashboard elements for our environment.

thebeardedgeek commented 3 years ago

@jeffg324 glad to hear that worked.

Here are two things to take into consideration.

  1. If you set the user's path via .profile or .bash_profile and run the SBMJOB command the script just needs node-red and that's it
  2. If you change the home directory of the user running the job or change directories to oss_scripts then you can simplify the SBMJOB command to SBMJOB CMD(QSH CMD('start-node.sh')) JOB(NODERED) JOBQ(QPGMR) USER(MATTDEV) Personally I like specifying the path so that it is explicit.
ThePrez commented 3 years ago

@jeffg324 , I think this is resolved, but feel free to reopen if you need more assistance. @thebeardedgeek , thanks for the help!