If all daemons are *always* meant to be started together, what about creating
a script that starts the them in sequence -- with some 'sleep' and/or
"wait-until-the-previous-daemon-becomes-available" in the middle -- and then
calling that script from rc.local?


On Jan 6, 2012, at 3:17 PM, keith wrote:

> On 06/01/2012 14:13, Zi Loff wrote:
>>
>>
>> I haven't tried it myself, so I have no idea if it works, but maybe you can
redirect stdout and stderr to a file... Something along the lines of:
>> (please note i added the -jar switch as well)
>>
>> echo  -n ' Graylog2-Server'; java -jar
/usr/local/graylog2-server/graylog2-server.jar 1> somefile 2>&1
>>
>>
>>
>> On Jan 6, 2012, at 2:06 PM, keith wrote:
>>
>>> On 06/01/2012 11:46, Zi Loff wrote:
>>>> On Jan 6, 2012, at 11:34 AM, keith wrote:
>>>>
>>>>> On 05/01/2012 16:43, keith wrote:
>>>>>> Hi, I have build a graylog2 server with obsd 5.0 x64 but can't figure
out how to get the some of the programs to auto start, They all start when run
as root but only the mogod one starts up at boot time. Can anyone help ?
>>>>>>
>>>>>> if [ -x /etc/rc.d/mongod ]; then
>>>>>>   echo -n ' MongoDB'; /etc/rc.d/mongod start
>>>>>> fi
>>>>>>
>>>>>> if [ -x /usr/local/elasticsearch/bin/elasticsearch  ]; then
>>>>>>   echo -n ' Elasticsearch';
/usr/local/elasticsearch/bin/elasticsearch&
>>>>>> fi
>>>>>>
>>>>>> if [ -x /usr/local/graylog2-server/graylog2-server.jar  ]; then
>>>>>>   echo  -n ' Graylog2-Server'; java
/usr/local/graylog2-server/graylog2-server.jar
>>>>>> fi
>>>>>>
>>>>>> if [ -x /usr/local/graylog2-server/graylog2-server.jar  ]; then
>>>>>>   echo -n ' Graylog2-Web';
/usr/local/graylog2-web-interface/script/rails server -e production&
>>>>>> fi
>>>>>>
>>>>>>
>>>>>> I've edited the /root/.profile and have added the path to  java to PATH
and also set JAVA_HOME.
>>>>>>
>>>>>> Thanks
>>>>>> Keith
>>>>> Taking advice for Zi and Otto I've moved on a little... The MongoDB and
Elastic Search are starting but Java / Graylog2-server and the Ruby /
Graylog2-Web-Interface still won't start.
>>>>> The current rc.local file looks like....
>>>>>
>>>>> if [ -x /etc/rc.d/mongod ]; then
>>>>>   echo -n ' MongoDB'; /etc/rc.d/mongod start
>>>>> fi
>>>>>
>>>>> export JAVA_HOME=/usr/local/jre-1.7.0/
>>>>>
>>>>> echo -n ' Run Elasticsearch:'
>>>>> sh /usr/local/elasticsearch/bin/elasticsearch&
>>>>>
>>>>> echo  -n ' Run Graylog2-Server:'
>>>>> cd  /usr/local/graylog2-server/
>>>>> /usr/local/jre-1.7.0/bin/java /usr/local/graylog2-server/graylog2-
>>>>> server.jar
>>>>>
>>>> Isn't the -jar option missing here?
>>>> ../java   -jar   /usr/local...
>>>>
>>>>> echo -n ' Run Graylog2-Web:'
>>>>> cd /usr/local/graylog2-web-interface/
>>>>> /usr/local/graylog2-web-interface/script/rails server -e production&
>>>>>
>>>>> And below is the text that appears at boot time.
>>>>>
>>>>> starting network daemons : sshd sendmail inetd.
>>>>> MongoDB mongod Run Elasticsearch: Run Graylog2-Server:Error: Could
>>>>> not find main class .usr.local.graylog2-server.graylog2-server.jar
>>>>> Exception in thread "main" java.land.NoClassDefFoundError: .
>>>>> usr.local.graylog2-server.graylog2-server.jar
>>>>>
>>>>> Then there's about 10 lines of java errors text then..
>>>>>
>>>>> Run Graylog2-Web:starting local daemons:env: ruby:  No such file or
>>>>> directory cron.
>>>>>
>>>>> When I log into the server as root and run the following as root then
>>>>> both the server and web-interface start fine.
>>>>>
>>>>> echo -n 'Graylog2-Server'
>>>>> cd  /usr/local/graylog2-server/
>>>>> java -jar graylog2-server.jar&
>>>>>
>>>>> echo -n 'Graylog2-Web'
>>>>> cd /usr/local/graylog2-web-interface/
>>>>> script/rails server -e production&
>>>>>
>>>>> Any help would be appreciated.
>>>>>
>>>>> Thanks
>>>>> Keith
>>>>>
>>> Thank you, that's made a difference. The Graylog2-Server isn't starting
but the error has changed...  Unfortunately the console scrolls so quickly I
can't see what the error is !!! Earlier today I tried to get a serial console
working but it didn't work earlier today when I tried. Probably because this
OSDB box is a virtual server running in VMware.
>>>
>>> I think / hope the errors are to do with the root profile.
>>>
>>> Thanks
>>> Keith
>>
>
> Thanks, It appears that elasticsearch doesn't have enough time to start.
I've tried putting a "sleep 20" into the rc.local file and although that did
work I don't get a login prompt on the console, tool it out reduced it to 15
seconds and still the same. Removed it completely and the login box has
returned. Strange.
>
> # cat /usr/local/graylog2-server-0.9.6/somefile
> 2012-01-06 14:54:07,553 FATAL: org.graylog2.Main - IOException while trying
to check Index. Make sure that your ElasticSearch server is running.
> java.net.ConnectException: Connection refused
>         at java.net.PlainSocketImpl.socketConnect(Native Method)
>         at
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:320)
>         at
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.jav
a:181)
>         at
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:163)
>         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:390)
>         at java.net.Socket.connect(Socket.java:578)
>         at java.net.Socket.connect(Socket.java:527)
>         at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
>         at sun.net.www.http.HttpClient.openServer(HttpClient.java:384)
>         at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)
>         at sun.net.www.http.HttpClient.<init>(HttpClient.java:213)
>         at sun.net.www.http.HttpClient.New(HttpClient.java:300)
>         at sun.net.www.http.HttpClient.New(HttpClient.java:312)
>         at
sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnectio
n.java:992)
>         at
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.ja
va:928)
>         at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:84
6)
>         at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.
java:1296)
>         at
java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:467)
>         at org.graylog2.indexer.Indexer.indexExists(Indexer.java:64)
>         at org.graylog2.Main.main(Main.java:131)

Reply via email to