0

how to start alljoynjs app automatically

asked 2015-03-25 08:17:02 -0700

AllJoyner gravatar image

I am wondering how we would make Alljoyn.js programs run automatically, instead of having to type "alljoynjs sampleProgram.js" . I am running it on Arduino Yun and want it to be available as soon as the board is powered up.

Thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-03-25 09:15:17 -0700

jprestwo gravatar image

The simplest way would be to modify /etc/rc.local and have it start up alljoynjs sampleProgram.js. Ensure its starting it as a background process as well:

alljoynjs sampleProgram.js &

Depending on how you are planning on using it you may not want to hard code the script into rc.local. I say this because any script that you install will be retained between boot cycles so once you install the first script using ajs_console it will always start up with that script. By hard coding the script in you will lose the ability change/modify the installed script through boot cycles because a fresh boot will always override the installed script with the original sampleProgram.js. I recommend just doing:

alljoynjs &

It really depends on your usage. If you have already written and tested a script and never plan on changing it then hard coding it is probably fine.

edit flag offensive delete publish link more

Comments

I am pretty much trying to achieve the same like I was able to with arduino due, where everything was running in a big loop. Could you give an example of how I would modify the /etc/rc.local exactly? Thanks

AllJoyner ( 2015-03-25 09:36:01 -0700 )edit

Open up and editor and add either of the commands to rc.local. By default it should be an essentially empty script with a comment explaining how to use it. rc.local is ran after the kernel boots up, it is used for exactly what you intend to do, start up user programs at boot. rc.local is ran as a bash script meaning it treats each line as if you typed it in a terminal window. Sorry if I wasn't clear in my answer, I sort of assume that everyone has bash/shell experience on here which is not the case a lot of the time.

jprestwo ( 2015-03-25 10:46:05 -0700 )edit

I am not able to test it now, but I am wondering how is "alljoynjs &" in rc.local by itself gonna know which particular script to run? Also,what is ajs_console exactly and does it come pre-installed,because i wasnt able to get it from jenkins when i was setting up(it says project currently disabled)

AllJoyner ( 2015-03-25 11:51:32 -0700 )edit

ajs_console allows you to remotely connect to an alljoynjs instance and do things like install scripts, do evals, or debug. If you have no intention of using the console then, yes, you will need to provide the script as the argument. BTW once you install a script, alljoynjs will store it in NVRAM and it will always be available when you start it up again (provided you don't overwrite it with a new script). This is why you will see the file ajlite.nvram in the directory that you start alljoynjs from. The benefit of not hard coding the script is that you could use the console and continue to develop the script and simply install it over the air when you have changes rather than ssh'ing onto the Yun, scp the script over and then run alljoynjs. This is the route I would personally go. If you ...(more)

jprestwo ( 2015-03-25 12:22:58 -0700 )edit

Just to confirm,it worked after hard coding the script using ssh.I like your suggestion to use ajs_console instead, I followed "Getting Started with AllJoyn.js" to get console client for windows but frankly i dont know how to set it up nor where exactly its located!? Thanks for help,appreciate it!

AllJoyner ( 2015-03-26 08:18:26 -0700 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2015-03-25 08:17:02 -0700

Seen: 188 times

Last updated: Mar 25 '15