2.0.0 4803e67

reload.go RawHistoryFolder

1package cmd
2
3import (
4	"fmt"
5	"os"
6	"path/filepath"
7	"syscall"
8
9	"github.com/spf13/cobra"
10)
11
12var reloadCmd = &cobra.Command{
13	Use:   "reload",
14	Short: "Reload configuration and environment variables into running containers",
15	Long: `Reload the Gordon configuration and environment variables from .env files into running containers.
16This command reloads the config file and redeploys all containers with updated environment 
17variables from their respective .env files. Containers are recreated to pick up the new configuration and environment variables.`,
18	Run: runReload,
19}
20
21func init() {
22	rootCmd.AddCommand(reloadCmd)
23}
24
25func runReload(cmd *cobra.Command, args []string) {
26	// Find the Gordon PID file to get the process ID
27	pidFile := findGordonPidFile()
28	if pidFile == "" {
29		fmt.Println("Error: Gordon PID file not found. Is Gordon running?")
30		fmt.Println("Please start Gordon with 'gordon start' first.")
31		return
32	}
33
34	// Read the PID from the file
35	pidBytes, err := os.ReadFile(pidFile)
36	if err != nil {
37		fmt.Printf("Error reading Gordon PID file: %v\n", err)
38		return
39	}
40
41	var pid int
42	if _, err := fmt.Sscanf(string(pidBytes), "%d", &pid); err != nil {
43		fmt.Printf("Error parsing Gordon PID: %v\n", err)
44		return
45	}
46
47	// Check if the process is still running
48	process, err := os.FindProcess(pid)
49	if err != nil {
50		fmt.Printf("Error finding Gordon process: %v\n", err)
51		return
52	}
53
54	// Send SIGUSR1 signal to trigger reload
55	if err := process.Signal(syscall.SIGUSR1); err != nil {
56		fmt.Printf("Error sending reload signal to Gordon: %v\n", err)
57		fmt.Println("Gordon may not be running or may not have permission to send signals.")
58		return
59	}
60
61	fmt.Println("Manual reload signal sent to Gordon successfully.")
62	fmt.Println("Check Gordon logs to see the reload progress.")
63}
64
65func findGordonPidFile() string {
66	// Look for PID file in common locations
67	locations := []string{
68		"/tmp/gordon.pid",
69		"/var/run/gordon.pid",
70		filepath.Join(os.TempDir(), "gordon.pid"),
71	}
72
73	// Also check in user's home directory
74	if homeDir, err := os.UserHomeDir(); err == nil {
75		locations = append(locations, filepath.Join(homeDir, ".gordon.pid"))
76	}
77
78	for _, location := range locations {
79		if _, err := os.Stat(location); err == nil {
80			return location
81		}
82	}
83
84	return ""
85}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close