Application started in Crontab, problems in communication between Nodejs and python
<p>I have developed an Bluetooth peripheral software (app.js) for Raspberry Pi using <a href="https://github.com/sandeepmistry/bleno" rel="nofollow">BLENO </a>NodeJS library. Inside my NodeJS application I'm calling some python script using <a href="https://github.com/extrabacon/python-shell" rel="nofollow">python-shell</a>. </p>

<p>I'm calling the python script using the following code:</p>

<pre><code>var shell = new PythonShell('example.py');
shell.on('message', function (message) {
  console.log(message);
</code></pre>

<p>My example.py is just simply prints number after some delay</p>

<pre><code>time.sleep(5)
print 10
</code></pre>

<p>When I start my app.js using command "node app.js" everything works as expected. Message callback is activated after 5 seconds delay and number 10 is printed to console.</p>

<p>However when I try to start the application when Rasperry Pi boots, Nodejs application never receives message from Python script. Python script prints the number to stdout, but for some reason it is not received by Nodejs app. Any suggestions?</p>

<p>Found a solution to my problem. Originally I started application from crontab using @reboot field. Instead of crontab, I started my application from /etc/init.d/. That fixed the problem. Maybe someone could explain the reason.</p>

python node.js raspberry-pi bleno