Skip to content

Commit

Permalink
Removed the old InstanceName variable
Browse files Browse the repository at this point in the history
There used to be a variable that gave a name to the Rails
process, it was used with older non-parallel web servers. With
puma this is no longer needed.
  • Loading branch information
prioux committed Feb 13, 2025
1 parent c37cd31 commit 8b4a4d9
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Bourreau/config/initializers/validation_bourreau.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
:z000_ensure_we_have_a_forwarded_ssh_agent,
])
end
Process.setproctitle "CBRAIN Console #{RemoteResource.current_resource.class} #{RemoteResource.current_resource.name} #{CBRAIN::Instance_Name}"
Process.setproctitle "CBRAIN Console #{RemoteResource.current_resource.class} #{RemoteResource.current_resource.name}"

# ----- SERVER -----
elsif program_name =~ /server|puma/ # normal server mode
Expand All @@ -68,7 +68,7 @@
# Note, because the puma server insists on renaming its process,
# the assignment below is also performed whenever a :show
# action is sent to the controls controller.
Process.setproctitle "CBRAIN Server #{RemoteResource.current_resource.class} #{RemoteResource.current_resource.name} #{CBRAIN::Instance_Name}"
Process.setproctitle "CBRAIN Server #{RemoteResource.current_resource.class} #{RemoteResource.current_resource.name}"

# ----- RSPEC TESTS -----
elsif program_name =~ /rspec/ # test suite
Expand Down
7 changes: 2 additions & 5 deletions BrainPortal/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,13 @@ def check_password_reset #:nodoc:
#
# The message looks like
#
# "User: tsmith on instance C4044 from example.com (256.0.0.9) using FireChrome 99.9"
# "User: tsmith from example.com (256.0.0.9) using FireChrome 99.9"
def log_user_info #:nodoc:
reqenv = request.env || {}

# Short username for the message
login = current_user ? current_user.login : "(none)"

# Find out the instance name
instname = CBRAIN::Instance_Name rescue "(?)"

# Get host and IP from session (when logged in)
from_ip = cbrain_session[:guessed_remote_ip].presence
from_host = cbrain_session[:guessed_remote_host].presence
Expand All @@ -204,7 +201,7 @@ def log_user_info #:nodoc:

# Create final message
from = (from_host.present? && from_host != from_ip) ? "#{from_host} (#{from_ip})" : from_ip
mess = "User: #{login} on instance #{instname} from #{from} using #{brow} #{b_ver}"
mess = "User: #{login} from #{from} using #{brow} #{b_ver}"
Rails.logger.info mess
true
rescue => ex
Expand Down
2 changes: 1 addition & 1 deletion BrainPortal/app/controllers/controls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def show

if keyword == 'info' || keyword == 'ping'
myself = RemoteResource.current_resource
Process.setproctitle "CBRAIN Server #{myself.class} #{myself.name} #{CBRAIN::Instance_Name}" # to override puma's process name
Process.setproctitle "CBRAIN Server #{myself.class} #{myself.name}" # to override puma's process name
@info = myself.remote_resource_info(keyword)
respond_to do |format|
format.html { head :method_not_allowed }
Expand Down
1 change: 0 additions & 1 deletion BrainPortal/app/models/exception_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def self.log_exception(exception, user, request)
}
e.session = session.to_hash
e.request_headers = hdrs
e.instance_name = CBRAIN::Instance_Name rescue "(?)"
e.revision_no = CBRAIN::CBRAIN_StartTime_Revision
e.save

Expand Down
1 change: 0 additions & 1 deletion BrainPortal/app/views/exception_logs/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<% t.cell("Parameters", :td_options => { :class => "wrap" }) { @exception_log.request[:parameters] } %>
<% t.cell("Format") { @exception_log.request[:format] } %>
<% t.cell("User") { @exception_log.user.try(:login) || "(Not signed in)" } %>
<% t.cell("Received by instance") { @exception_log.instance_name } %>
<% t.cell("Start time revision") { @exception_log.revision_no} %>
<% end %>

Expand Down
1 change: 0 additions & 1 deletion BrainPortal/app/views/layouts/_section_account.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
Rev: <%= CBRAIN::CBRAIN_StartTime_Revision %>
<% if current_user.present? && current_user.has_role?(:admin_user) %>
Branch: <%= git_branch %>
Instance:&nbsp;<%= CBRAIN::Instance_Name %>
<% end %>
</span>

Expand Down
8 changes: 0 additions & 8 deletions BrainPortal/config/initializers/cbrain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ class CBRAIN
ENV['PATH'] = "#{Rails.root.to_s}/vendor/cbrain/bin:#{ENV['PATH']}"
ENV['LD_LIBRARY_PATH'] = "#{Rails.root.to_s}/vendor/cbrain/lib:#{ENV['LD_LIBRARY_PATH']}"

# Instance name. An explicit name can be given by setting the environment variable
# 'CBRAIN_INSTANCE_NAME' before starting the process. Otherwise, we look at the
# current command line arguments and if we find '-p port', the name is set to
# 'port'. If all else fails, a string is built like "PID-#{pid}" with the process' PID.
Instance_Name = ENV['CBRAIN_INSTANCE_NAME'].presence ||
(ARGV.rindex('-p') && ARGV[ARGV.rindex('-p')+1]) ||
"PID-#{Process.pid}"

# CBRAIN plugins locations
Plugins_Dir = "#{Rails.root.to_s}/cbrain_plugins"
UserfilesPlugins_Dir = "#{Plugins_Dir}/installed-plugins/userfiles"
Expand Down
4 changes: 2 additions & 2 deletions BrainPortal/config/initializers/validation_portal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
CbrainSystemChecks.check(:all)
PortalSystemChecks.check(:all, :except => [ :z020_start_background_activity_workers ])
end
Process.setproctitle "CBRAIN Console #{RemoteResource.current_resource.class} #{RemoteResource.current_resource.name} #{CBRAIN::Instance_Name}"
Process.setproctitle "CBRAIN Console #{RemoteResource.current_resource.class} #{RemoteResource.current_resource.name}"

# ----- SERVER -----
elsif program_name =~ /server|puma/ # normal server mode
Expand All @@ -69,7 +69,7 @@
# Note, because the puma server insists on renaming its process,
# the assignment below is also performed whenever a show
# action is sent to the controls controller.
Process.setproctitle "CBRAIN Server #{RemoteResource.current_resource.class} #{RemoteResource.current_resource.name} #{CBRAIN::Instance_Name}"
Process.setproctitle "CBRAIN Server #{RemoteResource.current_resource.class} #{RemoteResource.current_resource.name}"

# ----- RSPEC TESTS -----
elsif program_name =~ /rspec/ # test suite
Expand Down
3 changes: 1 addition & 2 deletions BrainPortal/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20240613133122) do
ActiveRecord::Schema.define(version: 20250213205048) do

create_table "access_profiles", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci" do |t|
t.string "name", null: false
Expand Down Expand Up @@ -178,7 +178,6 @@
t.text "request", limit: 65535
t.text "session", limit: 65535
t.text "request_headers", limit: 65535
t.string "instance_name"
t.string "revision_no"
t.datetime "created_at"
t.datetime "updated_at"
Expand Down
1 change: 0 additions & 1 deletion BrainPortal/lib/cbrain_system_checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def self.print_intro_info #:nodoc:
puts "C> CBRAIN System Checks starting, " + Time.now.to_s
puts "C> Ruby #{RUBY_VERSION} on Rails #{Rails::VERSION::STRING}, environment is set to '#{Rails.env}'"
puts "C> RAILS_ENV variable is set to '#{ENV['RAILS_ENV']}'" if (! ENV['RAILS_ENV'].blank?) && (Rails.env != ENV['RAILS_ENV'])
puts "C> CBRAIN instance is named '#{CBRAIN::Instance_Name}'"
puts "C> Hostname is '#{Socket.gethostname rescue "(Exception)"}'"
#-----------------------------------------------------------------------------
end
Expand Down

0 comments on commit 8b4a4d9

Please sign in to comment.