Last active
January 15, 2020 15:54
-
-
Save vdegenne/0819880940520aa77f1587e1c8f5b914 to your computer and use it in GitHub Desktop.
Open the pm2 logs of the current project (current directory)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
pm_id=$(node <<EOF | |
const pm2_processes = `pm2 jlist`; | |
const pm2_process = pm2_processes.filter(proc => proc.pm2_env.pm_cwd === "`pwd`"); | |
if (pm2_process.length) { | |
// one process found | |
console.log(pm2_process[0].pm_id) | |
process.exit(0); | |
} | |
// else // not found | |
process.exit(1); | |
EOF | |
) | |
if [ $? -ne 0 ]; then | |
echo "pm2 process not found" | |
else | |
pm2 logs $pm_id | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script requires
pm2
andnodejs
to be installed on the system.