0

Here is my use-case. I have a long running server that is started by upstart. This server needs to be initialized first (populate tables in a db). This should only happen once in the life of the service (and again on migration), so can't be tied to a start/stop action.

How can I set this up in upstart? Can I set this up without having "start myservice-init; start myservice" ?

Reposted from https://stackoverflow.com/questions/24442123/upstart-init-task?noredirect=1#comment37820533_24442123 since it was put on hold there.

ekaqu
  • 113
  • 2

1 Answers1

0

Is there a way to check from sh whether the db population is needed? If so you can have it

start on starting myservice
task
pre-start script
    dbinitneeded || { stop; exit 0; }
end script
# init the db here with a script or exec
CameronNemo
  • 399
  • 1
  • 6
  • We want the setup to be explicit, so trying to figure out if a migration is needed is not something we can do. – ekaqu Jun 27 '14 at 22:06
  • Then just skip upstart entirely. Make it a little helper script, and exec it when needed. – CameronNemo Jun 27 '14 at 22:07