Skip to content

Commit

Permalink
Update microservice-orchestration/Step6 for live logs. (#238)
Browse files Browse the repository at this point in the history
Signed-off-by: Travis Hunt <[email protected]>
  • Loading branch information
thunt-career authored Mar 6, 2023
1 parent 9cfe3fd commit 032f83d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion _posts/2018-09-22-microservice-orchestration.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,6 @@ set :protection, :except=>:path_traversal
redis = Redis.new(url: ENV["REDIS_URL"] || "redis://localhost:6379")

Dir.mkdir("logs") unless Dir.exist?("logs")
cache_log = File.new("logs/extraction.log", "a")

get "/" do
"Usage: http://<hostname>[:<prt>]/api/<url>"
Expand All @@ -980,7 +979,9 @@ get "/api/*" do
redis.set(url, jsonlinks)
end

cache_log = File.open("logs/extraction.log", "a")
cache_log.puts "#{Time.now.to_i}\t#{cache_status}\t#{url}"
cache_log.close

status 200
headers "content-type" => "application/json"
Expand Down Expand Up @@ -1104,6 +1105,16 @@ Now, open the web interface by [clicking the Link Extractor](/){:data-term=".ter
Also, try to repeat these attempts for some URLs.
If everything is alright, the web application should behave as before without noticing any changes in the API service (which is completely replaced).

We can use the `tail` command with the `-f` or `--follow` option to follow the log output live.

```.term1
tail -f logs/extraction.log
```

Try a few more URLs in the web interface. You should see the new log entries appear in the terminal.

To stop following the log, press `Ctrl + C` keys while the interactive terminal is in focus.

We can shut the stack down now:

```.term1
Expand Down

0 comments on commit 032f83d

Please sign in to comment.