未知作业问题:Ubuntu Upstart Conf 虽然语法没问题

未知作业问题:Ubuntu Upstart Conf 虽然语法没问题

我正在尝试在 Ubuntu 14.04 中运行 Apache Solr 4.10.4 作为服务。

我已经编写了以下 upstart conf 文件:

sudo vim /etc/init/my-solr-job.conf

# my-solr - Search Backend Engine

description "my solr search engine"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
respawn limit 3 60

env JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"

exec $JAVA_HOME/bin/java -jar /home/xyzuser/solr-4.10.4/example/start.jar
#Tried this also
#exec /home/xyzuser/solr-4.10.4/bin/solr -f -p 8983

当我运行以下命令时,我得到以下输出:-

命令 1

init-checkconf -d /etc/init/my-solr.conf 
DEBUG: upstart_path=/sbin/init
DEBUG: initctl_path=/sbin/initctl
DEBUG: Setting XDG_RUNTIME_DIR='/tmp/init-checkconf.zPFmEfcI7D'
DEBUG: Unsetting UPSTART_SESSION (unix:abstract=/com/ubuntu/upstart-    session/1000/2037)
DEBUG: confdir=/tmp/init-checkconf.QFW9ZI7uGv
DEBUG: file=/etc/init/my-solr.conf
DEBUG: job=my-solr
DEBUG: upstart_out=/tmp/init-checkconf-upstart-output.ykMpMbTBU6
DEBUG: upstart_cmd=/sbin/init --user --no-dbus --no-startup-event --    verbose --confdir /tmp/init-checkconf.QFW9ZI7uGv
DEBUG: Upstart pid=5661
DEBUG: Joining Upstart session 'unix:abstract=/com/ubuntu/upstart-session/1000/5661'
DEBUG: Waiting for Upstart to initialise (attempt 1)
DEBUG: Secondary Upstart (/sbin/init --user --no-dbus --no-startup-    event --verbose --confdir /tmp/init-checkconf.QFW9ZI7uGv) running with PID 5661
File /etc/init/my-solr.conf: syntax ok
DEBUG: Restoring XDG_RUNTIME_DIR to '/run/user/1000'
DEBUG: Restoring UPSTART_SESSION to     'unix:abstract=/com/ubuntu/upstart-session/1000/2037'
DEBUG: Stopping secondary Upstart (running with PID 5661)

命令 2

initctl check-config my-solr
initctl: Invalid job class: my-solr

命令 3

initctl list | grep my-solr
<Output is nothing. I tried using initctl reload-configuration>

命令 4

sudo service my-solr start
start: Unknown job: my-solr

命令 5

ln -s /etc/init/my-solr.conf /etc/init.d/my-solr
<Did not make any difference>

有人能帮我解决这个问题吗?我不明白我做错了什么?

答案1

我取消设置了这个环境变量,它很好地工作了

env | grep UPSTART
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/2037

我使用的命令:

unset UPSTART_SESSION

但我还是不明白其根本原因。

我稍微修改了 conf 文件,因为当我试图停止这项工作时,它给了我 - 未知实例错误

以下是我的最终结论 -

# my-solr - Search Backend Engine

description "my solr search engine"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
respawn limit 3 60

env JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"

exec /home/xyzuser/solr-4.10.4/bin/solr start -f -p 8983
pre-stop exec /home/xyzuser/solr-4.10.4/bin/solr stop -f -p 8983

我使用了 pre-stop,因为 stop 正在向作业发送 SIGTERM,因此我尝试使用上面的方法正常停止作业。

相关内容