sandeepmistry / node-bleacon

A Node.js library for creating, discovering, and configuring iBeacons
MIT License
497 stars 88 forks source link

Bleacon not working on startup #76

Closed pmuno007 closed 7 years ago

pmuno007 commented 7 years ago

I want to execute a bleacon script I made on startup. I created a bash script with this command on it:

node /path/to/file/myScript.js

This works when I run it manually. When I add it to crontab, the following happens. The script starts (I have logging enabled so I can see that it runs), it goes through the startScanning() function, but the logic inside the on('discover'...} event is never hit.

I also tried putting the bash script on the init.d and do the update-rc.d myscript.js defaults route but the same issue described before happens.

Again, if I run the bash script manually, it calls my script and everything works. What could be the issue? How can I execute my bleacon script automatically on startup?

Note: I have tested putting other node scripts (not using bleacon) on this bash script and they are executed successfully.

tunelessly commented 7 years ago

I was having the same issue as you today. My "fix" was to include a sleep command before launching node. It's not ideal and I still don't know why this happens - though I suspect it has to do with an inconsistent, timing-sensitive issue with the bluetooth demon or something - but it works.

sandeepmistry commented 7 years ago

@pmuno007 @migmad I would make sure the script is started after bluetoothd is started.