mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-15 09:01:16 +00:00
tmux dtach
This commit is contained in:
parent
588d8b8d6a
commit
00be038cf3
1 changed files with 10 additions and 11 deletions
|
|
@ -11,19 +11,17 @@ let
|
||||||
|
|
||||||
piBin = "/home/${username}/.local/share/npm/bin/pi";
|
piBin = "/home/${username}/.local/share/npm/bin/pi";
|
||||||
|
|
||||||
# Wrapper that exec's pi inside tmux's foreground process so systemd
|
# Wrapper that runs pi inside dtach so it gets a PTY (systemd services
|
||||||
# tracks the actual PID. When pi dies, tmux exits, systemd sees it
|
# don't have a terminal) and can be attached to later for debugging:
|
||||||
# and triggers Restart=on-failure.
|
# dtach -a /run/pi-agent/pi-agent.sock
|
||||||
piAgentStart = pkgs.writeShellScript "start-pi-agent" ''
|
piAgentStart = pkgs.writeShellScript "start-pi-agent" ''
|
||||||
if [ ! -x "${piBin}" ]; then
|
if [ ! -x "${piBin}" ]; then
|
||||||
echo "pi binary not found at ${piBin}" >&2
|
echo "pi binary not found at ${piBin}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# tmux runs in the foreground (-D) so systemd tracks this process.
|
exec ${pkgs.dtach}/bin/dtach -N /run/pi-agent/pi-agent.sock \
|
||||||
# The inner shell exec's pi so the tmux pane PID *is* the pi PID.
|
${piBin} --chat-bridge
|
||||||
exec ${pkgs.tmux}/bin/tmux new-session -D -s pi-agent \
|
|
||||||
"exec ${piBin} --chat-bridge"
|
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -31,9 +29,10 @@ in
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d /var/lib/pi-agent 0750 ${username} users -"
|
"d /var/lib/pi-agent 0750 ${username} users -"
|
||||||
"z ${piAgentEnvFile} 0600 ${username} users -"
|
"z ${piAgentEnvFile} 0600 ${username} users -"
|
||||||
|
"d /run/pi-agent 0750 ${username} users -"
|
||||||
];
|
];
|
||||||
|
|
||||||
# Pi agent running 24/7 in a foreground tmux session.
|
# Pi agent running 24/7 inside dtach.
|
||||||
# Extensions (pi-channels, pi-schedule-prompt, pi-subagents) load
|
# Extensions (pi-channels, pi-schedule-prompt, pi-subagents) load
|
||||||
# inside Pi's process and handle Telegram bridging, scheduled tasks,
|
# inside Pi's process and handle Telegram bridging, scheduled tasks,
|
||||||
# and background subagent delegation.
|
# and background subagent delegation.
|
||||||
|
|
@ -42,8 +41,8 @@ in
|
||||||
# Telegram bot token lives in ~/.pi/agent/settings.json (see pi-channels docs).
|
# Telegram bot token lives in ~/.pi/agent/settings.json (see pi-channels docs).
|
||||||
# ANTHROPIC_API_KEY comes from the env file.
|
# ANTHROPIC_API_KEY comes from the env file.
|
||||||
#
|
#
|
||||||
# tmux session name: pi-agent
|
# Attach for debugging: dtach -a /run/pi-agent/pi-agent.sock
|
||||||
# Attach for debugging: tmux attach -t pi-agent
|
# Detach with: Ctrl+\
|
||||||
systemd.services.pi-agent = {
|
systemd.services.pi-agent = {
|
||||||
description = "Pi Coding Agent (24/7)";
|
description = "Pi Coding Agent (24/7)";
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
|
|
@ -52,7 +51,7 @@ in
|
||||||
path = [
|
path = [
|
||||||
pkgs.nodejs_22
|
pkgs.nodejs_22
|
||||||
pkgs.git
|
pkgs.git
|
||||||
pkgs.tmux
|
pkgs.dtach
|
||||||
pkgs.coreutils
|
pkgs.coreutils
|
||||||
];
|
];
|
||||||
environment = {
|
environment = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue