newBike
newBike

Reputation: 15022

How to run unicorn when reboot automatically, I got Could not find gems errors

I setup my rbenv in .zshrc and on Ubuntu 12.04

and get the following errors

Could not find tzinfo-0.3.40 in any of the sources Runbundle installto install missing gems.

Here's the command in the crontab

/bin/sh -l -c 'source ~/.zshrc && cd /home/poc/projects/zeus/ && bundle exec unicorn -c /home/poc/projects/zeus/config/unicorn.rb -E production -D -p 8080'

When I typed which ruby, I expected it returned me /home/poc/.rbenv/shims/ruby But /usr/local/bin/ruby

/bin/sh -l -c 'source ~/.zshrc; echo `which ruby`'

Upvotes: 1

Views: 181

Answers (2)

You could consider using a crontab(5) entry, using the @reboot nickname date

You certainly want /bin/zsh, not /bin/sh, in your crontab since you want to use zsh

But it would be simpler to write your sh script for it. Read for instance the advanced bash scripting guide.

You might want to set your PATH (perhaps even at the start of that script) to suite your specific needs.

Upvotes: 1

newBike
newBike

Reputation: 15022

To fix my problem, I have to enable the rbenv environment at first,

You should change the following command to fit in your environment

I put the following line in crontab,

At first You should do

export PATH=/home/poc/.rbenv/shims:/home/poc/.rbenv/bin:/usr/bin:$PATH; eval "$(rbenv init -)"; 

Upvotes: 0

Related Questions