我正在尝试为teamspeak服务器制作一个简单的新贵脚本,但无法使其工作。
当我说initctl start它只是执行但永远不会完成甚至发出任何消息。stop也发生了同样的事情。
为了确保我没有做错任何事情,我复制了 cron 脚本并尝试运行它,但它发生了同样的情况。
我在这里做错了什么?
更新:
这是我的 TS3 脚本:
# myservice - myservice job file
description "my service description"
author "Me <myself@i.com>"
# Stanzas
#
# Stanzas control when and how a process is started and stopped
# See a list of stanzas here: http://upstart.ubuntu.com/wiki/Stanzas#respawn
# When to start the service
start on runlevel [2345]
# When to stop the service
stop on runlevel [016]
# Automatically restart process if crashed
respawn
# Essentially lets upstart know the process will detach itself to the background
expect fork
# Start the process
script
emit going into TS3 dir
chdir /home/danizmax/teamspeak3-server_linux-x86/
emit starting TS3
exec su -c "/home/danizmax/teamspeak3-server_linux-x86/ts3server_startscript.sh start" danizmax &
emit done
end script
Run Code Online (Sandbox Code Playgroud)
我什至尝试使用最简单的脚本,但这也不起作用:
description "regular background program processing daemon"
start on runlevel [2345]
stop on runlevel [!2345]
expect fork
respawn
exec echo example
console output
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助。
在你这个新贵的工作中,有很多奇怪的地方让我摸不着头脑。
1)emit不是我所知道的程序,因此除非您将其添加到系统路径中,否则可能会导致错误。您指的是 'echo' 吗? 这可能也没有帮助,因为它将转到可能不可见的系统控制台。
2)假设 'emit' 节有效,你说 'expect fork' 但实际上 fork两次。一次用于“脚本”,然后当 teampeak 脚本分叉到后台时再次进行。
3)你“su”来运行脚本,但在大多数情况下start-stop-daemon实际上更简单:
在 11.10 中,您不需要执行chdirin 脚本,不确定是否是在您拥有的任何版本的 upstart 之后添加的。检查一下man 5 init有没有这个词chdir
start on runlevel [2345]
stop on runlevel [^2345]
respawn
chdir /home/danizmax/teamspeak-server
expect fork
exec start-stop-daemon --start --user danizmax --group danizmax --exec /home/danizmax/teamspeak3-server_linux-x86/ts3server_startscript.sh -- start
Run Code Online (Sandbox Code Playgroud)
此外,错误可能会在 /var/log/syslog 中报告。您可以通过运行来大大增加错误级别
initctl log-priority info
Run Code Online (Sandbox Code Playgroud)
man initctl更多日志级别。
| 归档时间: |
|
| 查看次数: |
5503 次 |
| 最近记录: |