使用start-stop-daemon的Solr upstart脚本

时间:2014-10-23 07:19:54

标签: ubuntu solr upstart start-stop-daemon

我想使用upstart命令启动我的solr。

我用来正常启动太阳能的命令是

/usr/bin/java \
-Dsolr.solr.home=/home/justeat/work/projects/solr/apache-solr-4.0.0/example/solr \
-Djetty.port=8983 \
-Djetty.logs=/home/justeat/work/projects/solr/apache-solr-4.0.0/example/solr/logs \
-Djetty.home=/home/justeat/work/projects/solr/apache-solr-4.0.0/example \
-Djava.io.tmpdir=/tmp \
-jar /home/justeat/work/projects/solr/apache-solr-4.0.0/example/start.jar

现在,当我使用

DAEMON_OPTS="-Dsolr.solr.home=/home/bitnami/search/solr/solr-4.2.1/example/solr -Djetty.port=8983 -Djetty.logs=/home/bitnami/search/solr/solr-4.2.1/example/logs -Djetty.home=/home/bitnami/search/solr/solr-4.2.1/example -Djava.io.tmpdir=/tmp -jar /home/bitnami/search/solr/solr-4.2.1/example/start.jar"

exec /usr/bin/java ${DAEMON_OPTS} >> /var/log/log.log 2>&1

Upstart工作正常。当我尝试使用start-stop-daemon和upstart脚本时,solr没有得到我在DAEMON_OPTS发送的一些参数。

exec start-stop-daemon \
        --start \
        --make-pidfile \
        --pidfile /var/run/solr_upstart.pid \
        --chuid $USER \
        --exec /usr/bin/java -- $DAEMON_OPTS >> /var/log/log.log 2>&1

Solr日志在下面,

2014-10-23 12:32:15.878:INFO:oejs.Server:jetty-8.1.2.v20120308
2014-10-23 12:32:15.932:INFO:oejdp.ScanningAppProvider:Deployment monitor /home/justeat/work/projects/solr/apache-solr-4.0.0/example/contexts at interval 0
2014-10-23 12:32:15.946:INFO:oejd.DeploymentManager:Deployable added: /home/justeat/work/projects/solr/apache-solr-4.0.0/example/contexts/solr.xml
2014-10-23 12:32:16.056:WARN:oejx.XmlConfiguration:Config error at <Set name="tempDirectory"><Property name="jetty.home" default="."/>/solr-webapp</Set> java.lang.reflect.InvocationTargetException
2014-10-23 12:32:16.056:WARN:oejd.DeploymentManager:Unable to reach node goal: started
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:565)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:378)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:338)
    at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:291)
    at org.eclipse.jetty.deploy.providers.ContextProvider.createContextHandler(ContextProvider.java:68)
    at org.eclipse.jetty.deploy.App.getContextHandler(App.java:97)
    at org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:33)
    at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:183)
    at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:491)
    at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:138)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:142)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:53)
    at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:604)
    at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:535)
    at org.eclipse.jetty.util.Scanner.scan(Scanner.java:398)
    at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:332)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:118)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:552)
    at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:227)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:63)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:53)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:91)
    at org.eclipse.jetty.server.Server.doStart(Server.java:263)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1215)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1138)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.jetty.start.Main.invokeMain(Main.java:457)
    at org.eclipse.jetty.start.Main.start(Main.java:602)
    at org.eclipse.jetty.start.Main.main(Main.java:82)
Caused by: 
java.lang.IllegalArgumentException: Bad temp directory: /solr-webapp
    at org.eclipse.jetty.webapp.WebAppContext.setTempDirectory(WebAppContext.java:1098)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:565)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:378)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:338)
    at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:291)
    at org.eclipse.jetty.deploy.providers.ContextProvider.createContextHandler(ContextProvider.java:68)
    at org.eclipse.jetty.deploy.App.getContextHandler(App.java:97)
    at org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:33)
    at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:183)
    at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:491)
    at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:138)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:142)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:53)
    at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:604)
    at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:535)
    at org.eclipse.jetty.util.Scanner.scan(Scanner.java:398)
    at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:332)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:118)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:552)
    at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:227)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:63)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:53)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:91)
    at org.eclipse.jetty.server.Server.doStart(Server.java:263)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1215)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1138)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.jetty.start.Main.invokeMain(Main.java:457)
    at org.eclipse.jetty.start.Main.start(Main.java:602)
    at org.eclipse.jetty.start.Main.main(Main.java:82)
2014-10-23 12:32:16.081:INFO:oejs.AbstractConnector:Started SocketConnector@0.0.0.0:8983

2 个答案:

答案 0 :(得分:1)

我没有使用完全相同的设置,但我收到了相同的错误消息。罪魁祸首是在更改凭据后,在每次启动Solr时,/opt/solr-5.1.0/server/webapps/solr.war下的WAR文件被解压缩到/opt/solr-5.1.0/server/solr-webapp/。因此,对于运行Solr的用户来说,该路径必须是可写的(或者您可以更改一些配置,我猜)。

答案 1 :(得分:0)

一些想法:

  • Upstart可能会默默地缩短exec节
  • s-s-d(start-stop-daemon)可能正在这样做
  • 也许您对选项的数量或大小达到了内核限制?

最好的办法是:

  • 从s-s-d的选项中删除--pidfile--make-pidfile选项,它们对Upstart无用
  • 删除重定向到/var/log/log.log,只需依靠Upstart来捕获stdout / err
  • 考虑使用Upstart的setuid节并完全删除s-s-d调用