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

Commit

Permalink
portusctl: fixed the location of crono logs
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mssola committed Jan 22, 2016
1 parent dfc72b3 commit add79d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions packaging/suse/portusctl/lib/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def logs(*args)
ensure_root

Runner.produce_versions_file!
Runner.produce_crono_log_file!
Runner.tar_files("log/production.log", "log/crono.log", "log/versions.log")
end

Expand Down
16 changes: 15 additions & 1 deletion packaging/suse/portusctl/lib/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
class Runner
# Run a simple external command
def self.exec(cmd, args = [])
final_cmd = cmd + " " + args.map { |a| Shellwords.escape(a) }.join(" ")
final_cmd = Runner.escape_command(cmd, args)
unless system(final_cmd)
raise "Something went wrong while invoking: #{final_cmd}"
end
end

# Returns a string containing the command with its arguments all escaped.
def self.escape_command(cmd, args = [])
cmd + " " + args.map { |a| Shellwords.escape(a) }.join(" ")
end

# Run an external command using the bundler binary shipped with Portus' RPM
def self.bundler_exec(cmd, args, extra_env_variables)
Dir.chdir(PORTUS_ROOT) do
Expand Down Expand Up @@ -42,6 +47,15 @@ def self.produce_versions_file!
end
end

# Creates a new file called "crono.log" with the logs stored by systemd about
# crono.
def self.produce_crono_log_file!
File.open(File.join(PORTUS_ROOT, "log/crono.log"), "w+") do |file|
cmd = Runner.escape_command("journalctl", ["--no-pager", "-u", "portus_crono"])
file.puts(`#{cmd}`)
end
end

# Tar and compress the given files into the /tmp directory. It's assumed that
# these files are located inside of PORTUS_ROOT.
def self.tar_files(*files)
Expand Down

0 comments on commit add79d7

Please sign in to comment.