
Estou tentando iniciar algumas coisas na inicialização do CentOS, mas estou encontrando alguns problemas que não sei como resolver.
Aqui está o arquivo my.service:
[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
Depois systemctl daemon-reload
, systemctl enable my.service
e systemctl start my.service
, nada realmente parece acontecer/funcionar.
A saída de systemctl status my.service
é:
$ 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.
Supostamente, as coisas deveriam ter funcionado, mas não funcionam...
No entanto, se eu executar manualmente o boot.sh, elas funcionarão.
su ...
./boot.sh
boot.sh é:
#!/bin/bash
nohup java -jar /var/jenkins/slave.jar -jnlpUrl https://***.jnlp -secret **** &
/var/sonarqube-6.3/bin/linux-x86-64/sonar.sh start
Observe que o SonarQube requer root.
O que estou fazendo de errado?
Atualizar:registros de 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.
Responder1
Para o SonarQube acabei seguindo isto:https://devopscube.com/setup-and-configure-sonarqube-on-linux/, que instrui como adicionar o SonarQube como um serviço... que era estranhamente mais simples do que a abordagem do systemd.
Para o primeiro comando no arquivo, isso ainda é um problema em aberto...