-1

I have an init.d script to start up god on my server after a reboot.

I've run sudo chmod +x /etc/init.d/god and sudo update-rc.d -f god defaults and when I run /etc/init.d/god start as the deploy user I have no issues and god starts.

However, when I reboot the server god doesn't start.

When I try and start god manually as root I get this error:

Your Ruby version is 1.9.3, but your Gemfile specified 2.3.0

I believe the issue is something to do with root not having rvm or ruby 2.3.0. Is there a way to run the init.d script as deploy?

I'm on Ubuntu 14.04, ruby 2.3.0 and god 0.13.7

c.nj
  • 35
  • 2
  • 8
  • Initialization scripts are running from superuser. Hence, superuser environment is used. And your target machine seems to have Ruby 1.9.3 version installed in su env. The easiest way to fix it is: run `sudo su` and install `rvm` and then Ruby 2.3 _as superuser_. – Aleksei Matiushkin Feb 11 '16 at 11:57
  • I'd rather not install ``rvm`` as root since this would mean maintaining the ruby version as root and deploy for any future updates. If I forget to do this and god went down i'd have a lot of issues. – c.nj Feb 11 '16 at 12:38

1 Answers1

0

You can run any command (or execute a script) as any user with the sudo command; just use the -u flag to specify the user. Example:

sudo -u deploy /etc/init.d/god

See more here: http://www.sudo.ws/man/1.8.15/sudo.man.html

Steve Benner
  • 1,679
  • 22
  • 26
  • Thanks for the help but running ``sudo -u deploy /etc/init.d/god start`` still gives me ruby version error. – c.nj Feb 11 '16 at 12:38
  • If you are getting a Bundler error then you should check your Gemfile and Bundler configuration to make sure it matches the ruby installed on the system. – Steve Benner Feb 11 '16 at 12:44