0

当我在 CentOS 7 上安装 Rocket.Chat 服务器时,我创建了rocketchat.service

[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target 
mongod.target[Service]
Type=simple
ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=root
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat 
ROOT_URL=http://www.leavenotrace.cn PORT=3000
[Install] WantedBy=multi-user.target

当我按下命令时:

systemctl start rocketchat
systemctl status rocketchat

显示以下错误:

Apr 18 11:50:13 VM_56_252_centos systemd[1]: [/etc/systemd/system/rocketchat.service:3] Failed to add dependency on mongod.target[Service], ignoring: Invalid argument
Apr 18 11:50:13 VM_56_252_centos systemd[1]: [/etc/systemd/system/rocketchat.service:4] Unknown lvalue 'Type' in section 'Unit'
Apr 18 11:50:13 VM_56_252_centos systemd[1]: [/etc/systemd/system/rocketchat.service:5] Unknown lvalue 'ExecStart' in section 'Unit'
Apr 18 11:50:13 VM_56_252_centos systemd[1]: [/etc/systemd/system/rocketchat.service:6] Unknown lvalue 'Restart' in section 'Unit'
Apr 18 11:50:13 VM_56_252_centos systemd[1]: [/etc/systemd/system/rocketchat.service:7] Unknown lvalue 'StandardOutput' in section 'Unit'
Apr 18 11:50:13 VM_56_252_centos systemd[1]: [/etc/systemd/system/rocketchat.service:8] Unknown lvalue 'StandardError' in section 'Unit'
Apr 18 11:50:13 VM_56_252_centos systemd[1]: [/etc/systemd/system/rocketchat.service:9] Unknown lvalue 'SyslogIdentifier' in section 'Unit'
Apr 18 11:50:13 VM_56_252_centos systemd[1]: [/etc/systemd/system/rocketchat.service:10] Unknown lvalue 'User' in section 'Unit'
Apr 18 11:50:13 VM_56_252_centos systemd[1]: [/etc/systemd/system/rocketchat.service:11] Unknown lvalue 'Environment' in section 'Unit'
Apr 18 11:50:13 VM_56_252_centos systemd[1]: [/etc/systemd/system/rocketchat.service:12] Invalid section header '[Install] WantedBy=multi-user.target'
4

1 回答 1

0

前:

nano /etc/systemd/system/rocketchat.service

它将显示这些错误。

后:

nano /usr/lib/systemd/system/rocketchat.service

在里面写:

  [Unit]
  Description=The Rocket.Chat server
  After=network.target remote-fs.target nss-lookup.target nginx.target mongod.target
  [Service]
  ExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js
  StandardOutput=syslog
  StandardError=syslog
  SyslogIdentifier=rocketchat
  User=root
  Environment=MONGO_URL=mongodb://localhost:27017/rocketchat ROOT_URL=http://www.leavenotrace.cn:3000/ PORT=3000
  [Install]
  WantedBy=multi-user.target

还行吧。

于 2017-04-18T05:54:10.293 回答