Skip to content

Commit

Permalink
Pull request #49: Update to remove fluentd
Browse files Browse the repository at this point in the history
Merge in COSMOSEE/base from remove-fluent-cosmos to master

* commit '832ed93f28f6db66ceb217af4e511def03a4314b':
  rm cosmos-frontend-init
  Update to remove fluentd
  • Loading branch information
van Andel, Gerhard committed Mar 23, 2021
2 parents 8f888d5 + 832ed93 commit b597b23
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 32 deletions.
1 change: 0 additions & 1 deletion cosmos/cosmos.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ spec = Gem::Specification.new do |s|
s.add_runtime_dependency 'puma', '~> 5.0'
s.add_runtime_dependency 'rack', '~> 2.0'
s.add_runtime_dependency 'httpclient', '~> 2.8'
s.add_runtime_dependency 'fluent-logger', '~> 0.8'
s.add_runtime_dependency 'redis', '~> 4.2'
s.add_runtime_dependency 'childprocess', '~> 3.0'
s.add_runtime_dependency 'connection_pool', '~> 2.2'
Expand Down
20 changes: 3 additions & 17 deletions cosmos/lib/cosmos/utilities/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
require 'thread'
require 'logger'
require 'time'
require 'fluent-logger'

module Cosmos

Expand Down Expand Up @@ -71,23 +70,16 @@ class Logger
FATAL_SEVERITY_STRING = 'FATAL'

# @param level [Integer] The initial logging level
def initialize(level = Logger::INFO, stdout = false)
def initialize(level = Logger::INFO)
@level = level
@scope = nil
@detail_string = nil
@stdout = stdout
@container_name = Socket.gethostname
@microservice_name = nil
@metric_tag = @container_name + ".metric"
@tag = @container_name + ".log"
@mutex = Mutex.new
@no_fluentd = ENV['NO_FLUENTD']
@no_store = ENV['NO_STORE']
unless @no_fluentd
fluentd_url = ENV['COSMOS_FLUENTD_URL'] || (ENV['COSMOS_DEVEL'] ? 'http://127.0.0.1:24224' : 'http://cosmos-fluentd:24224')
path = fluentd_url.split('/')[-1].split(':')
Fluent::Logger::FluentLogger.open(nil, { host: path[0], port: path[1] })
end
end

# @param message [String] The message to print if the log level is at or
Expand Down Expand Up @@ -199,17 +191,14 @@ def log_metric(data, scope:, &block)
if block_given?
data = yield
end
Fluent::Logger.post(@metric_tag, data) unless @no_fluentd
puts data.to_json
unless @no_store
if scope
Store.write_topic("#{scope}__cosmos_log_messages", data)
else
Store.write_topic("cosmos_log_messages", data)
end
end
if @stdout
puts "#{Time.now.sys.formatted} #{@detail_string ? "(#{@detail_string}):" : ''} #{data.to_json}"
end
end
end

Expand All @@ -223,17 +212,14 @@ def log_message(severity_string, message, scope:, &block)
end
data[:container_name] = @container_name
data[:log] = message
Fluent::Logger.post(@tag, data) unless @no_fluentd
puts data.to_json
unless @no_store
if scope
Store.write_topic("#{scope}__cosmos_log_messages", data)
else
Store.write_topic("cosmos_log_messages", data)
end
end
if @stdout
puts "#{Time.now.sys.formatted} #{@detail_string ? "(#{@detail_string}):" : ''} #{severity_string}: #{message}"
end
end
end

Expand Down
13 changes: 6 additions & 7 deletions scripts/linux/cosmos_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,24 @@ sleep 30

docker build -f cmd_tlm_api/Dockerfile -t cosmos-cmd-tlm-api cmd_tlm_api
docker container rm cosmos-cmd-tlm-api
docker run --network cosmos -p 127.0.0.1:2901:2901 -d --name cosmos-cmd-tlm-api --env NO_FLUENTD=1 cosmos-cmd-tlm-api
docker run --network cosmos -p 127.0.0.1:2901:2901 -d --name cosmos-cmd-tlm-api cosmos-cmd-tlm-api

docker build -f script_runner_api/Dockerfile -t cosmos-script-runner-api script_runner_api
docker container rm cosmos-script-runner-api
docker run --network cosmos -p 127.0.0.1:2902:2902 -d --name cosmos-script-runner-api --env NO_FLUENTD=1 cosmos-script-runner-api
docker run --network cosmos -p 127.0.0.1:2902:2902 -d --name cosmos-script-runner-api cosmos-script-runner-api

docker build -f operator/Dockerfile -t cosmos-operator operator
docker container rm cosmos-operator
docker run --network cosmos -d --name cosmos-operator --env NO_FLUENTD=1 cosmos-operator
docker run --network cosmos -d --name cosmos-operator cosmos-operator

docker container rm cosmos-traefik
docker build -f traefik/Dockerfile -t cosmos-traefik traefik
docker run --network cosmos -p 127.0.0.1:2900:80 -d --name cosmos-traefik --env NO_FLUENTD=1 cosmos-traefik
docker run --network cosmos -p 127.0.0.1:2900:80 -d --name cosmos-traefik cosmos-traefik

docker build -f frontend/Dockerfile -t cosmos-frontend-init frontend
docker container rm cosmos-frontend-init
docker run --network cosmos --name cosmos-frontend-init --env NO_FLUENTD=1 cosmos-frontend-init
docker run --network cosmos --name cosmos-frontend-init --rm cosmos-frontend-init

docker build -f init/Dockerfile -t cosmos-init init
docker run --network cosmos --name cosmos-init --rm --env NO_FLUENTD=1 cosmos-init
docker run --network cosmos --name cosmos-init --rm cosmos-init

echo "If everything is working you should be able to access Cosmos at http://localhost:2900/"
13 changes: 6 additions & 7 deletions scripts/windows/cosmos_start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,24 @@ timeout 30 >nul

docker container rm cosmos-cmd-tlm-api
docker build -f cmd_tlm_api\Dockerfile -t cosmos-cmd-tlm-api cmd_tlm_api
docker run --network cosmos -p 127.0.0.1:2901:2901 -d --name cosmos-cmd-tlm-api --env NO_FLUENTD=1 cosmos-cmd-tlm-api
docker run --network cosmos -p 127.0.0.1:2901:2901 -d --name cosmos-cmd-tlm-api cosmos-cmd-tlm-api

docker container rm cosmos-script-runner-api
docker build -f script_runner_api\Dockerfile -t cosmos-script-runner-api script_runner_api
docker run --network cosmos -p 127.0.0.1:2902:2902 -d --name cosmos-script-runner-api --env NO_FLUENTD=1 cosmos-script-runner-api
docker run --network cosmos -p 127.0.0.1:2902:2902 -d --name cosmos-script-runner-api cosmos-script-runner-api

docker container rm cosmos-operator
docker build -f operator\Dockerfile -t cosmos-operator operator
docker run --network cosmos -d --name cosmos-operator --env NO_FLUENTD=1 cosmos-operator
docker run --network cosmos -d --name cosmos-operator cosmos-operator

docker container rm cosmos-traefik
docker build -f traefik\Dockerfile -t cosmos-traefik traefik
docker run --network cosmos -p 127.0.0.1:2900:80 -d --name cosmos-traefik --env NO_FLUENTD=1 cosmos-traefik
docker run --network cosmos -p 127.0.0.1:2900:80 -d --name cosmos-traefik cosmos-traefik

docker build -f frontend\Dockerfile -t cosmos-frontend-init frontend
docker container rm cosmos-frontend-init
docker run --network cosmos --name cosmos-frontend-init --env NO_FLUENTD=1 cosmos-frontend-init
docker run --network cosmos --name cosmos-frontend-init --rm cosmos-frontend-init

docker build -f init\Dockerfile -t cosmos-init init
docker run --network cosmos --name cosmos-init --rm --env NO_FLUENTD=1 cosmos-init
docker run --network cosmos --name cosmos-init --rm cosmos-init

REM If everything is working you should be able to access Cosmos at http://localhost:2900/

0 comments on commit b597b23

Please sign in to comment.