Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

264
Views
Nodejs no es completamente funcional cuando se ejecuta en inicio automático

Actualmente estoy tratando de cambiar el volumen de mi Raspberry Pi con dos botones html (subir volumen y bajar volumen), usando nodeJS. El cambio de volumen se realiza llamando a un script bash al hacer clic en uno de los botones html en index.html.

Cuando inicio el nodo manualmente desde la terminal con

node server.js

todo funciona bien y puedo subir y bajar el volumen usando los dos botones. Tan pronto como puse el script del nodo en inicio automático, solo funciona el botón "Subir volumen", mientras que el botón Bajar volumen no parece funcionar.

Matando el proceso de nodo autoiniciado e iniciándolo manualmente, funciona bien de nuevo. ¿Cómo puede el resultado ser tan diferente, dependiendo de cómo se inicie el nodo aquí? ¿Cuál es mi error en esto?

Mi secuencia de comandos de nodo se ve así:

 var express = require('express'); var path = require('path'); var open = require('open'); var fs = require('fs'); const { exec } = require('child_process'); var bodyParser = require('body-parser'); var port = 3000; var app = express(); app.get('/', function(req, res){ res.sendFile(path.join(__dirname, 'index.html')); }); app.use(bodyParser.urlencoded({ extended: false })); app.post('/', function(request, respond) { var inputValue = request.body.volume; if (inputValue == "up") { exec('sh volumeup.sh'); } if(inputValue == "down") { exec('sh volumedown.sh'); } }); app.listen(port, function(err){ if(err){ console.log(err); }else{ open('http://localhost:' + port); } });

con mi index.html:

 <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> </head> <body> <h2>Change Volume</h2> <form action="" method="post"> <button name="volume" value="up">Volume Up</button> <button name="volume" value="down">Volume Down</button> </form> </body> </html>

Para que nodejs se ejecute en el inicio automático, configuré un archivo * .desktop:

 [Desktop Entry] Encoding=UTF-8 Type=Application Name=<Node> Comment= Exec=/usr/bin/node /home/pi/Desktop/server.js StartupNotify=false Terminal=true Hidden=false

Muchas gracias de antemano, agradezco mucho su ayuda!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!