2

I am attempting to start a couple of things on startup in CentOS, but I'm encountering some issues I don't know how to solve.

Here is my.service file:

[Unit]
Description="Boot Jenkins slave and SonarQube server"
After=network.target

[Service]
Type=simple
ExecStart=/var/boot.sh
User=root
Group=root

[Install]
WantedBy=default.target

After systemctl daemon-reload, systemctl enable my.service and systemctl start my.service, nothing actually seem to happen/work.

The output of systemctl status my.service is:

$ systemctl status my.service 
● startup.service - "Boot Jenkins slave and SonarQube server"
   Loaded: loaded (/etc/systemd/system/my.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Wed 2017-04-26 19:49:31 IDT; 1min 41s ago
  Process: 988 ExecStart=/var/boot.sh (code=exited, status=0/SUCCESS)
 Main PID: 988 (code=exited, status=0/SUCCESS)

Apr 26 19:49:00 build-1 systemd[1]: Started "Boot Jenkins slave and SonarQube server".
Apr 26 19:49:00 build-1 systemd[1]: Starting "Boot Jenkins slave and SonarQube server"...
Apr 26 19:49:00 build-1 boot.sh[988]: Starting SonarQube...
Apr 26 19:49:01 build-1 boot.sh[988]: Started SonarQube.

Supposedly, things should have worked, but they don't...
However, if I will manually run boot.sh, they do work.

su ...
./boot.sh

boot.sh is:

#!/bin/bash

nohup java -jar /var/jenkins/slave.jar -jnlpUrl https://***.jnlp -secret **** &
/var/sonarqube-6.3/bin/linux-x86-64/sonar.sh start

Note that SonarQube requires root.
What am I doing wrong?

Update: logs from cat /var/log/messages | grep SonarQube:

Apr 26 20:58:53 build-1 systemd: Started "Boot Jenkis slave and SonarQube server".
Apr 26 20:58:53 build-1 systemd: Starting "Boot Jenkis slave and SonarQube server"...
Apr 26 20:58:53 build-1 boot.sh: Starting SonarQube...
Apr 26 20:58:53 build-1 boot.sh: Started SonarQube.
8
  • Try checking the logs with journalctl -xe, it should tell you what is happening...
    – l'L'l
    Commented Apr 26, 2017 at 18:12
  • Unfortunately no error is logged there, or anything related to the above.
    – Idan Adar
    Commented Apr 26, 2017 at 18:14
  • Then maybe try doing cat /var/log/messages | grep SonarQube. The inactive status might not be what you think it is; services can become inactive until they are needed, so it's actually loaded and enabled.
    – l'L'l
    Commented Apr 26, 2017 at 18:34
  • But not actually started, as the server is still offline. See updated question (bottom) for the log.
    – Idan Adar
    Commented Apr 26, 2017 at 18:37
  • When the script is run via systemd, it never finishes IMO, and when it is run manually, it does (as I do su and then run it).
    – Idan Adar
    Commented Apr 26, 2017 at 18:39

1 Answer 1

0

For SonarQube I ended up just following this instead: https://devopscube.com/setup-and-configure-sonarqube-on-linux/, which instructs how to add SonarQube as a service... that was oddly quite simpler than the systemd approach.

For the first command in the file, that's still an open issue...

1
  • SonarQube is still being managed by systemd, but now it's happening through a sysVinit compatibility layer. Commented Apr 26, 2017 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .