Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 1bd45d8

Browse files
committed
portusctl: fixed the location of crono logs
Since we don't daemonize it, crono's logs are sent to stdout. Since we manage it with systemd, logs are accessible through journalctl, not on /srv/Portus/log/crono.log. Signed-off-by: Miquel Sabaté Solà <[email protected]>
1 parent 93259fc commit 1bd45d8

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

packaging/suse/portusctl/lib/cli.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def logs(*args)
136136
ensure_root
137137

138138
Runner.produce_versions_file!
139+
Runner.produce_crono_log_file!
139140
Runner.tar_files("log/production.log", "log/crono.log", "log/versions.log")
140141
end
141142

packaging/suse/portusctl/lib/runner.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
class Runner
33
# Run a simple external command
44
def self.exec(cmd, args = [])
5-
final_cmd = cmd + " " + args.map { |a| Shellwords.escape(a) }.join(" ")
5+
final_cmd = Runner.escape_command(cmd, args)
66
unless system(final_cmd)
77
raise "Something went wrong while invoking: #{final_cmd}"
88
end
99
end
1010

11+
# Returns a string containing the command with its arguments all escaped.
12+
def self.escape_command(cmd, args = [])
13+
cmd + " " + args.map { |a| Shellwords.escape(a) }.join(" ")
14+
end
15+
1116
# Run an external command using the bundler binary shipped with Portus' RPM
1217
def self.bundler_exec(cmd, args, extra_env_variables)
1318
Dir.chdir(PORTUS_ROOT) do
@@ -42,6 +47,15 @@ def self.produce_versions_file!
4247
end
4348
end
4449

50+
# Creates a new file called "crono.log" with the logs stored by systemd about
51+
# crono.
52+
def self.produce_crono_log_file!
53+
File.open(File.join(PORTUS_ROOT, "log/crono.log"), "w+") do |file|
54+
cmd = Runner.escape_command("journalctl", ["--no-pager", "-u", "portus_crono"])
55+
file.puts(`#{cmd}`)
56+
end
57+
end
58+
4559
# Tar and compress the given files into the /tmp directory. It's assumed that
4660
# these files are located inside of PORTUS_ROOT.
4761
def self.tar_files(*files)

0 commit comments

Comments
 (0)