Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM --platform=linux/amd64 ubuntu:20.04
MAINTAINER docker@ipepe.pl
LABEL author="docker@ipepe.pl"

# setup envs
ENV DEBIAN_FRONTEND=noninteractive LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
Expand Down
2 changes: 1 addition & 1 deletion rootfs/start_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
system("service #{service_name} start")
end

if SERVICE_NAMES.include?("foremand-supervisor")
if SERVICE_NAMES.include?("foremand-supervisor".to_sym)
system("foremand start")
end
2 changes: 1 addition & 1 deletion rootfs/usr/local/bin/foremand
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'socket'

if ARGV.empty?
puts "Usage: foremand <start|stop|status>"
puts "Usage: foremand <start|stop|status|prekillsidekiq>"
exit 1
elsif !['start', 'stop', 'status', 'prekillsidekiq'].include?(command = ARGV[0].downcase)
puts "Unknown command. Usage: formand <start|stop|status|prekillsidekiq>"
Expand Down
12 changes: 9 additions & 3 deletions rootfs/usr/local/bin/foremand-supervisor
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def start_foreman(io = $stdout, app_env = "production")

Dir.chdir APP_ROOT
FileUtils.mkdir_p LOG_DIR
foreman_cmd = "RAILS_ENV=#{app_env} #{MALLOC_ENV} #{FOREMAN_BIN} start -f #{PROCFILE} -d #{APP_ROOT} -e #{APP_ROOT}/.env.#{app_env} > #{LOG_DIR}/foreman.log 2>&1"
dotenv_if_present = load_dotenv_if_present(app_env)
foreman_cmd = "RAILS_ENV=#{app_env} #{MALLOC_ENV} #{FOREMAN_BIN} start -f #{PROCFILE} -d #{APP_ROOT} #{dotenv_if_present} > #{LOG_DIR}/foreman.log 2>&1"
cmd_as_webapp = "sh -c \"#{foreman_cmd}\" webapp"
foreman_pid = spawn(cmd_as_webapp)
Process.detach(foreman_pid)
Expand Down Expand Up @@ -149,7 +150,7 @@ def setup_signal_handling
end

if ARGV.empty?
puts "Usage: foremand-supervisor start"
puts "Usage: foremand-supervisor <start|run>"
exit 1
elsif ARGV[0].downcase == "start"
daemonize
Expand All @@ -159,6 +160,11 @@ elsif ARGV[0].downcase == "start"
elsif ARGV[0].downcase == "run"
start_server(ARGV[1] || "production")
else
puts "Unknown command. Usage: formand start"
puts "Unknown command. Usage: formand <start|run>"
exit 1
end

def load_dotenv_if_present(app_env)
return "-e #{APP_ROOT}/.env.#{app_env}.local" if File.exist?("#{APP_ROOT}/.env.#{app_env}.local")
return "-e #{APP_ROOT}/.env.#{app_env}" if File.exist?("#{APP_ROOT}/.env.#{app_env}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good, can you also add support for .env.#{app_env}.local?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added per suggestion, but I have changed the order to match https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use

.env.x.local takes precedence over .env.x

end