Let us say you want to see realtime some logs like those coming from your lean release, deploy and e2e pipeline. Here is how to use rtail to expose logs streams on a web interface:
Expose streams using rtail-server
sudo npm install -g rtail
mkdir ~/rtail-server
cd ~/rtail-server
Create a process.yaml in that directory
apps:
- script : rtail-server
name: 'rtail-server'
instances: 0
exec_mode: cluster
merge_logs: true
args: "--web-port 8080 --web-host 0.0.0.0"
Run it
pm2 start process.yaml
pm2 save
# logs are in ~/.pm2
Stream logs via rtail client with simple and effective cron:
* * * * * ( flock -n 1 || exit 0; tail -F /var/log/ci/release.log | rtail --id "release.log" ) 1>~/rtail-release.lock
* * * * * ( flock -n 2 || exit 0; tail -F /var/log/ci/gke-deploy.log | rtail --id "deploy.log" ) 2>~/rtail-deploy.lock
* * * * * ( flock -n 3 || exit 0; tail -F /var/log/ci/e2e.log | rtail --id "e2e.log" ) 3>~/rtail-e2e.lock
At this point http://localhost:8080 should list the available streams and the log traces coming in from them.
WARNING: At the time of this writing there is a stream mixed output bug you should be aware of (https://github.com/kilianc/rtail/issues/110) . To go around it use the below:
sudo cp /usr/local/lib/node_modules/rtail/cli/rtail-server.js /usr/local/lib/node_modules/rtail/cli/rtail-server.js.old
sudo curl https://raw.githubusercontent.com/mfornasa/rtail/ed16d9e54d19c36ff2b76e68092cb3188664719f/cli/rtail-server.js -o /usr/local/lib/node_modules/rtail/cli/rtail-server.js
ps -ef | grep rtail-server | grep -v grep | awk '{print $2}' | xargs kill
diff /usr/local/lib/node_modules/rtail/cli/rtail-server.js /usr/local/lib/node_modules/rtail/cli/rtail-server.js.old
Just refresh your browser and wait till the streams show up again.
No comments:
Post a Comment