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.
journalctl -xe
, it should tell you what is happening...cat /var/log/messages | grep SonarQube
. Theinactive
status might not be what you think it is; services can becomeinactive
until they are needed, so it's actually loaded and enabled.su
and then run it).