Shells and logs
Get into your environment, your projects, and your containers over SSH.
The SSH user you connect as picks where you land:
1ssh cd.pico.sh # a shell in your projects directory
2ssh web@cd.pico.sh # a shell in a project
3ssh web@cd.pico.sh ls # a command in a project
4ssh c-web-web-1@cd.pico.sh # a shell in a container
5ssh l-web-web-1@cd.pico.sh # follow a container's logs
6ssh a-web-web-1@cd.pico.sh # attach to a container
Containers are named as compose names them: <project>-<service>-<n>.
status <project> lists them.
You always log in as your own account, the one your SSH key belongs to.
~<owner> in the SSH user picks whose projects you act on, such as a
team's, and whoami shows both:
1ssh '~pico@cd.pico.sh' whoami
Shells and commands in your environment get the same as variables:
PICD_USER is your account, PICD_OWNER whose projects you're in, and
PICD_PROJECT the project, in a project's directory. Shells and commands in
a project also get its environment variables.
Shells that resume #
Your shells run in tmux, so a dropped connection doesn't end them. Your next shell in the same place, your projects directory or the same project, attaches the shell you were in, with whatever it was running. A second shell while the first is connected gets a new one.
tmux's status bar shows the project you're in and your windows. tmux's
keys start with Ctrl-b:
| Keys | |
|---|---|
Ctrl-b c |
A new window |
Ctrl-b n, Ctrl-b p |
The next or previous window |
Ctrl-b % |
Split the pane side by side |
Ctrl-b " |
Split the pane top and bottom |
Ctrl-b and an arrow |
Move to another pane |
Ctrl-b d |
Detach, leaving the shell to resume later |
Ctrl-b ? |
List every key |
The mouse selects panes and windows, and scrolls. ~/.tmux.conf changes
any of this. A shell left detached for a week is closed.
To use plain shells instead:
1mkdir -p ~/.config/picd && touch ~/.config/picd/no-tmux
Updates to your environment end its shells. picd holds an update while you
have pushes, deploys, or commands running, and for up to 6 hours while only
shells and logs are open. Commands run in a terminal, with ssh -t, count as
shells. Your shells get a minute's warning first.
Your home directory #
Your home, ~, is kept in /data/home, so your dotfiles, ~/.ssh keys
and config, ~/.gitconfig, and docker login credentials survive restarts
and updates. It starts with picd's default shell setup, which you can change
like any other file. Webhook deploys use
the SSH keys and config there.
Updates to picd's default setup don't change a home that exists. To start over from the latest default:
1ssh cd.pico.sh home reset
Your previous home moves to /data/home.old, replacing an older one there.
Copy back what you want to keep, such as ~/.ssh.
Logs #
logs shows a project's last 100 lines from every service, or from the
services you name, and -f keeps following them:
1ssh cd.pico.sh logs web
2ssh cd.pico.sh logs web db -f
Your docker engine #
Your shell has docker and docker compose for your own engine, so you can
inspect, restart, and debug your containers:
1ssh cd.pico.sh
2docker ps
3docker logs --tail 50 web-web-1
compose <project> <args> runs docker compose in a project without a
shell, with the same compose files a deploy uses:
1ssh cd.pico.sh compose web ps -a
2ssh cd.pico.sh compose web restart db
Your shell runs as root beside your engine: it sees every process in your
environment, as htop shows, and shares its network. That also lets it stop
docker or break its networking. If your environment gets stuck, restart it:
1ssh cd.pico.sh restart
Everything in it stops and starts again, with your repositories, projects, volumes, and home kept. Your shells end, and your apps restart.
To stop your environment and its apps until you next need them:
1ssh cd.pico.sh shutdown --confirm
Without --confirm, shutdown only says what it would do. Your data is
kept, and the environment starts again the next time you connect, push, or
run a command that needs it. Add --delete to also remove the environment
itself, so it's created afresh when it next starts.