Skip to content

Commit

Permalink
Add parent_id in pg response and some misc helper queries
Browse files Browse the repository at this point in the history
  • Loading branch information
var77 committed May 3, 2024
1 parent 052923d commit 633ec79
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions misc/misc_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,24 @@ class MiscOperations
def self.update_rhizome_from_local(vm, target_folder: "lantern", user: "lantern")
update_rhizome(vm.sshable, target_folder, user)
end

def self.docker_logs(resource_name, tail: 10)
LanternResource[name: resource_name].representative_server.vm.sshable.cmd("sudo docker logs lantern-postgresql-1 --tail #{tail} -f")
end

def self.docker_env(resource_name)
LanternResource[name: resource_name].representative_server.vm.sshable.cmd("sudo cat /var/lib/lantern/.env")
end

def self.mem_info(resource_name)
LanternResource[name: resource_name].representative_server.vm.sshable.cmd("free -mh")
end

def self.kill_query(resource_name, pid)
LanternResource[name: resource_name].representative_server.run_query("SELECT pg_terminate_backend(#{pid})")
end

def self.task_logs(resource_name, task_name)
LanternResource[name: resource_name].representative_server.vm.sshable.cmd("common/bin/daemonizer --logs #{task_name}")
end
end
4 changes: 4 additions & 0 deletions misc/misc_queries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ def self.update_collation(resource)
resource.representative_server.run_query("ALTER DATABASE #{db} REFRESH COLLATION VERSION")
end
end

def self.active_queries(resource_name)
LanternResource[name: resource_name].representative_server.run_query("SELECT pid, query FROM pg_stat_activity")
end
end
1 change: 1 addition & 0 deletions serializers/api/lantern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def self.base(pg)
{
id: pg.id,
ubid: pg.ubid,
parent_id: pg.parent_id,
path: pg.path,
name: pg.name,
state: pg.display_state,
Expand Down

0 comments on commit 633ec79

Please sign in to comment.