diff options
author | Arseniy Zaostrovnykh <arseniy.zaostrovnykh@sonarsource.com> | 2025-02-18 11:08:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-18 11:08:26 +0100 |
commit | d3c2bd6599a5ba2a44eeaa6a99863450635877e8 (patch) | |
tree | 42e3fd0588934c499ebe03aa15815e3cfc1254c3 | |
parent | f0a0395ac7af90839b579dafd7c2728607b06ecf (diff) | |
download | sonarqube-az/ps-wide-output.tar.gz sonarqube-az/ps-wide-output.zip |
Make sonar startup script insensitive to the terminal widthaz/ps-wide-output
Surprizingly, even when `ps` output is piped into another command, such as `grep` in this case, it is still truncated based on the terminal width.
Depending on how wide your terminal you get different results from running the same command:
Wide-enough terminal:
```
./sonar.sh start
/usr/bin/java
Starting SonarQube...
Started SonarQube.
```
Not-wide-enough terminal (width = 263 columns):
```
sonar.sh start
/usr/bin/java
Starting SonarQube...
Removed stale pid file: ./SonarQube.pid
Failed to start SonarQube.
```
To fix that, `ps` should be run with `-ww` option, see the [man page](https://man7.org/linux/man-pages/man1/ps.1.html)
Tested on `ps` version 4.0.3 and 3.3.17
-rwxr-xr-x | sonar-application/src/main/assembly/bin/linux-x86-64/sonar.sh | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sonar-application/src/main/assembly/bin/linux-x86-64/sonar.sh b/sonar-application/src/main/assembly/bin/linux-x86-64/sonar.sh index 8f0408e1190..25893e29292 100755 --- a/sonar-application/src/main/assembly/bin/linux-x86-64/sonar.sh +++ b/sonar-application/src/main/assembly/bin/linux-x86-64/sonar.sh @@ -117,7 +117,7 @@ getpid() { # common is during system startup after an unclean shutdown. # The ps statement below looks for the specific wrapper command running as # the pid. If it is not found then the pid file is considered to be stale. - pidtest=`$PSEXE -p $pid -o args | grep "sonar-application-@sqversion@.jar" | tail -1` + pidtest=`$PSEXE -p $pid -o args -ww | grep "sonar-application-@sqversion@.jar" | tail -1` if [ "X$pidtest" = "X" ] then # This is a stale pid file. |