Referring to Running Nodejs As a Service - Systemd
I can't debug with console.log('running on ...');
Here is my nodeserver.service
[Unit]
Description=Nodeserver
[Service]
ExecStart=/usr/bin/node /var/www/web/nodeserver.js
Type=simple
Restart=on-abort
[Install]
WantedBy=multi-user.target
and this is nodeserver.js:
process.chdir(__dirname);
var express = require('express');
var app = express();
var config = require('./config');
app.listen(3000, function(){ console.log('running on port 3000'); });
the server is running perfectly, no errors, and I can access it from browser like: http://example.com:3000
every thing is great.
Now, ff I run the server like node server.js
, it prints running on port 3000
in the terminal screen, but when I start it as service like: systemctl start nodeserver
, the server start but it doesn't log any thing in the terminal.
I found something about journalctl
, but that's not good enough. Something missing somewhere.
How can I get results from console.log
when start it from service?