2

I'm trying to use upstart for the first time. I have two java programs that i want to start. The first one is a solr search server running on jetty, and the second one is a custom crawler that should start after the solr server started.

my crawler init script looks like this:

description     "crawler"
author ""

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

respawn

script
    cd /home/crawler
    java -Duser.timezone=Europe/Berlin  -jar crawler.jar
end script

Now for the solr server i wrote this:

description     "server"

start on starting crawler
stop on runlevel [!2345]

respawn

script
    cd /home/server/version0.1/example
    java -Duser.language=en -Dsolr.clustering.enabled=true -Duser.country=US  -Dfile.encoding=UTF-8 -jar start.jar
end script

both get started so it seems to work, but i want the crawler to be started after a little delay of say 2 seconds, to give the server time to enable everything. Anyone knows how to do this? What do you think about the two upstart scripts are they okay or did i miss something? (I'm a total init noob)

samy
  • 1,396
  • 2
  • 19
  • 41

2 Answers2

5

Replace starting with started

start on started crawler
Aigars Matulis
  • 1,469
  • 17
  • 22
  • and what's a syntax for stop? `stop on stopped crawler` ? – Lord_JABA Apr 04 '14 at 08:58
  • should work, why don't you try it? read http://upstart.ubuntu.com/cookbook/ and http://upstart.ubuntu.com/getting-started.html 6.33.2 Stop before depended-upon service `stop on stopping other-service` 6.33.3 Stop after dependent service `stop on stopped other-service` – Aigars Matulis Apr 05 '14 at 14:35
1

I think adding a sleep 2 will pause the script for a 2 seconds and should be a solution.

Muhammad Gelbana
  • 3,890
  • 3
  • 43
  • 81