Skip to content

Instantly share code, notes, and snippets.

@vovimayhem
Last active February 25, 2019 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vovimayhem/ccf6f3057b42bdf110c8b321bc7ea7c3 to your computer and use it in GitHub Desktop.
Save vovimayhem/ccf6f3057b42bdf110c8b321bc7ea7c3 to your computer and use it in GitHub Desktop.
Changes to common rails wrapper script
#!/usr/bin/env ruby
# This file is located at `bin/rails`
# Load the 'switch_user_and_exec' routine:
require_relative '../config/switch_user_and_exec'
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
# This file is located at `config/switch_user_and_exec.rb`
require 'etc'
info = Etc.getpwuid
if info.name == 'root' && (target_user = ENV['DEVELOPER_USER'])
puts "Switching from 'root' user to '#{target_user}'..."
exec 'su-exec', target_user, $0, *$*
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment