Skip to content

Commit

Permalink
feat: add systemd config, remove agent prefix logging (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredallard authored Jun 19, 2024
1 parent ffc8ba9 commit 0a51c59
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cmd/minecraft-preempt-agent/minecraft-preempt-agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"time"

logger "github.com/charmbracelet/log"
"github.com/egym-playground/go-prefix-writer/prefixer"
"github.com/jaredallard/minecraft-preempt/v3/internal/cloud"
"github.com/jaredallard/minecraft-preempt/v3/internal/cloud/docker"
"github.com/jaredallard/minecraft-preempt/v3/internal/cloud/gcp"
Expand Down Expand Up @@ -72,9 +71,9 @@ func entrypoint(cCmd *cobra.Command, args []string) error {

log.With("version", version.Version, "cloud", cloudProvider).Info("starting agent")

cmd := exec.CommandContext(ctx, "docker", "compose", "-f", dc, "up")
cmd.Stdout = prefixer.New(os.Stdout, func() string { return "[docker-compose] " })
cmd.Stderr = prefixer.New(os.Stderr, func() string { return "[docker-compose] " })
cmd := exec.CommandContext(ctx, "docker", "compose", "-f", dc, "up", "--no-log-prefix")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

// Start the process in a new process group so we can kill it and all
// of its children reliably. This also detaches ^C (sent to us) from
Expand Down
14 changes: 14 additions & 0 deletions contrib/minecraft-preempt-agent.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Minecraft Preempt Agent
After=network.target

[Service]
ExecStart=minecraft-preempt-agent
# Change to the path where your docker-compose file is.
WorkingDirectory=/home/worker/minecraft
User=ubuntu
Group=ubuntu
Restart=always

[Install]
WantedBy=multi-user.target

0 comments on commit 0a51c59

Please sign in to comment.