centos7非centos标准服务 /etc/init.d/service_name start || stop 启动异常

公司自己写的java程序,在centos7系统执行/etc/init.d/service_name start||stop的时候报错:

grafana二次开发的程序

[root@docp1 init.d]# /etc/init.d/grafana status
● grafana.service - LSB: Start grafana at boot time
   Loaded: loaded (/etc/rc.d/init.d/grafana; bad; vendor preset: disabled)
   Active: activating (start) since 三 2019-04-10 11:46:19 CST; 9s ago
     Docs: man:systemd-sysv-generator(8)
  Control: 103931 (bash)
   CGroup: /system.slice/grafana.service
           ├─103931 bash /etc/rc.d/init.d/grafana start
           └─103998 sleep 1

4月 10 11:46:19 docp1 systemd[1]: Starting LSB: Start grafana at boot time...
4月 10 11:46:19 docp1 su[103941]: (to root) root on none
4月 10 11:46:19 docp1 grafana[103931]: Starting Grafana Server: ... [  OK  ]
[root@docp1 init.d]# /etc/init.d/grafana start
Starting grafana (via systemctl):  Job for grafana.service failed because the control process exited with error code. See "systemctl status grafana.service" and "journalctl -xe" for details.
                                                           [失败]

切换至/etc/init.d,然后去启动该服务,正常

CentOS 7继承了RHEL 7的新的特性,比如强大的systemctl,而systemctl的使用也使得以往系统服务的/etc/init.d的启动脚本的方式就此改变,当执行/etc/init.d/service.name start || stop,系统默认回去调用systemctl start || stop service.name 去执行,

DOCP&&BDP大多数程序非centos标准包
因此:非centos7标准安装的服务启动脚本,无法通过/etc/init.d/service.name这种方式去启动,需先进入到/etc/init.d目录下,然后service.name start || stop 去执行。

CentOS 7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,像须要开机不登陆就能执行的程序,还是存在系统服务里吧,即:/usr/lib/systemd/system文件夹下

原文地址:https://www.cnblogs.com/sunshine-long/p/10682565.html