Skip to content

Commit 032f83d

Browse files
authored
Update microservice-orchestration/Step6 for live logs. (#238)
Signed-off-by: Travis Hunt <[email protected]>
1 parent 9cfe3fd commit 032f83d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

_posts/2018-09-22-microservice-orchestration.markdown

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,6 @@ set :protection, :except=>:path_traversal
964964
redis = Redis.new(url: ENV["REDIS_URL"] || "redis://localhost:6379")
965965

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

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

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

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

1108+
We can use the `tail` command with the `-f` or `--follow` option to follow the log output live.
1109+
1110+
```.term1
1111+
tail -f logs/extraction.log
1112+
```
1113+
1114+
Try a few more URLs in the web interface. You should see the new log entries appear in the terminal.
1115+
1116+
To stop following the log, press `Ctrl + C` keys while the interactive terminal is in focus.
1117+
11071118
We can shut the stack down now:
11081119

11091120
```.term1

0 commit comments

Comments
 (0)