Keeping the computer awake when you leave
The Agent runs at your place. A sleeping computer means stopped work — here is the setting for macOS, Windows and Linux.
The Agent runs on your computer. When the computer goes to sleep, it goes to sleep with it — and on your phone you see that the Server stopped answering, in the middle of work you gave it a moment ago. This is a setting you make once and then never think about.
The difference between “the screen sleeps” and “the computer sleeps” is crucial: a dark display does not bother the Agent, a sleeping system does.
macOS
The simplest way is to start the Server through caffeinate, which keeps the system awake only while that command runs. No permanent setting you would then go looking for:
$ caffeinate -s coden start --dir ~/projekty/muj-projekt
The -s switch prevents the system from sleeping while it is plugged in. On battery add -i as well, otherwise the laptop sleeps even with it.
Permanently it can be set in Settings → Battery → Options: “Prevent automatic sleeping when the display is off”. A closed lid puts the laptop to sleep regardless — for that only an external monitor, or power plus an unlocked state, helps.
Windows
Settings → System → Power & battery → Screen and sleep. Set “When plugged in, put my device to sleep after” to “Never”. Let the display go dark, that does not bother the Agent.
It works from the command line too, and that is quicker than clicking through the menus:
> powercfg /change standby-timeout-ac 0
> powercfg /change hibernate-timeout-ac 0
Zero means “never”. The suffix -ac applies to mains power; for battery it is -dc.
Linux
On a computer with a graphical environment turn automatic sleep off in the power settings. On a server or an environment without GNOME, systemd is enough:
$ sudo systemctl mask sleep.target suspend.target hibernate.target
A closed lid is handled by /etc/systemd/logind.conf — the entry HandleLidSwitch=ignore and then sudo systemctl restart systemd-logind.
And what if the computer goes to sleep anyway?
Nothing breaks. The Agent stops working where it was and the Server loses the connection. After waking the Server runs on and the phone connects to it on its own — but the unfinished turn will not complete and will have to be given again.
That is why that one evening of setting it up pays off. The worst state is thinking the Agent is working while it has been asleep for half an hour.
Stuck somewhere other than what is here? Write to support@coden-app.com.