Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

238
Visualizações
Loggly not working via Winston on Pi

I have an IoT project running on a Raspberry Pi 2 using the Raspbian Jessie OS.

It's a web server running in NodeJS (v4) and I'm using Winston to log to Loggly's logging service. All works well when the project is kicked off via npm start from terminal (when running as 'pi' or via sudo -s). However, when the project starts on boot, the logging doesn't work and I can't work out why.

To start the project on boot I created a etc/init.d script. The project starts and serves traffic, everything works great except for logging. I can't see any errors (though not having logging doesn't help). This is how I start my project from inside my etc/init.d script:

/usr/bin/node /var/www/curtains/server.js

I'm using winston: https://www.npmjs.com/package/winston and winston-loggly: https://www.npmjs.com/package/winston-loggly.

Any ideas why, when the process is started on bootup the logging doesn't work?

Adding winston initialization code as requested:

var winston = require('winston');
require('winston-loggly');

 winston.add(winston.transports.Loggly, {
    token: "<snip>",
    subdomain: "<snip>",
    tags: ["tag", ip.address()],
    json:true
});

winston.log('info',"Server.js starting up");
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

When you run npm start, node will look for a scripts object in your package.json file, and run the commands associated with the start key.

In your init.d script you are not running npm start, but instead just running node and passing your server.js file as the first argument (which will run that file).

Most likely, something in your start script is needed in order to run your logging correctly. To solve this, you can either:

  • In your init.d script, cwd to your project root and then run npm start.
  • Look in your package.json to see what else your start script is doing, and add the equivalent to your init.d script.
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda