How to start Chia GUI at startup in Ubuntu?

I want to switch to Ubuntu, but last time I tried I had a hard time getting this to work.

So I want to run Chia at startup (GUI), without the need to login first, say in case of power failure/reboot.
In Windows you add a shortcut to the startup folder, how do you do this in Ubuntu?

Alternatively, I would also like to know why my Windows 10 suddenly refuses to load Chia a startup. I now first have to login, while that never used to be the case…

1 Like

Starting GUI before logging in is logically impossible, because operating system UI doesn’t initialize until you have logged in.

When I used Windows, I added Chia GUI in the startup apps, and found a utility to automatically log in the user with pre-saved password and lock screen.

But all these problems go away if you simply run CLI. Just register it as a service and chia start farmer will initialize daemon in background. This way you can run it even when OS has no UI or in a container environment.

For Ubuntu there is now a chia-blockchain-cli package available, makes install/update process seamless

3 Likes

search web for light desktop for ubuntu too

install chia "sudo dpkg -i filename.deb "

1 Like

The GUI just displays information from Chia services that run in the background (and starts them automatically if they’re not running).

You can use a systemd service to start the node, farmer, and wallet on startup, then if you open the GUI later, it’ll find these processes.

Something like this should work:

[Unit]
Description=chia farmer
Wants=network-online.target
After=network.target network-online.target
StartLimitIntervalSec=0

[Service]
Type=forking
Restart=always
RestartSec=10
User=ubuntu

ExecStart=/usr/bin/env PATH=/home/ubuntu/chia-blockchain/venv/bin:$PATH chia start farmer -r
ExecStop=/usr/bin/env PATH=/home/ubuntu/chia-blockchain/venv/bin:$PATH chia stop all -d

[Install]
WantedBy=multi-user.target

You’ll need to replace User=ubuntu with whatever your account username is and update the path /home/ubuntu/chia-blockchain/ to the location where Chia is installed to (note, this may not work with the Debian package and needs to be installed from git).

Save as /lib/systemd/system/chia-farmer.service, run systemctl daemon-reload && systemctl enable chia-farmer and then test with sudo systemctl start chia-farmer

The services should be running in the background. Watch the Chia logs and use the CLI to determine if it’s working or not.

4 Likes

If you’re on Ubuntu, you don’t have to run the GUI to get the harvester going… it’s a simple one line add into crontab to start the farmer/harvester at reboot. Check out my blog post here on xchdev.com for details.

3 Likes

Actually windows does this just fine, i just fucked some setting and dont know which. I tested it multiple times before. If you add it to the startup folder Chia will load and be farming without a user login.

Thanks i know i can go that way, i just prefer to run the full program so that when i take a look it will be running and showing me stuff instead of just a bunch of lines in a terminal.

I guess my question is, if it is that easy to run the command line app, why not the gui app. There must be some executable command that you can run at startup right? If you can run it by clicking on it there has to be a corresponding command behind it.

1 Like

On Linux, a GUI application cannot run without a “display” being active. On Ubuntu, there is no active display until you first log in to your account and start a new desktop session. If you have to enter your password or click a button to log in when you first boot up Ubuntu, then there’s no display for the GUI to attach to in order to run.

So you have a few options…you could set up an automatic login so that your password is stored and used to automatically log in to a desktop session on boot, then from there have the blockchain GUI run when the user session starts.

Running the farmer on boot with a systemd service as I suggested previously will also work. When the machine boots (but before anyone logs in) all the Chia services will start up and run in the background. Then, if/when you log in to your desktop session, you can start the GUI normally and it’ll attach to the running Chia processes instead of starting them automatically. Note: If you close the GUI, it’ll then stop all the background processes and stop farming.

The Debian installer and source install from Git work a bit differently, so the paths will need to be adjusted depending on which version is installed.

Bottom line though, you can’t run the GUI on Linux unless you first have an active desktop session. This could be your regular desktop session, or you could install a secondary display manager for VNC-style connections (like XRDP). You can run the Chia services without a desktop session, but the GUI requires a desktop session running in order to start up.

Edited to add: here’s a good reference on Linux displays xorg - How does Linux's display work? - Unix & Linux Stack Exchange

2 Likes

You can run GUI applications on a headless server without any desktop session running, you just need the X libraries etc installed.

On the server you can run at runlevel 3 i.e.

root@node:~ # systemctl get-default
multi-user.target
root@node:~ # runlevel
N 3

Then use something like xpra instead of a full desktop. On the server side start the chia GUI like this as the chia user:

xpra start :100 --start-child="chia-blockchain" &

On the client:

xpra detach ssh/chia@node:22/100 ; xpra attach ssh/chia@node:22/100 &

This client command connects to the xpra server with an SSH tunnel as the user “chia”. The 100 is just a number in case you want to run several GUI apps. The first detach prevents attaching twice if there are issues.

Server side, if you place this xpra start/stop in the systemd startup scripts posted above this should start the chia GUI after a reboot at runlevel 3. Haven’t tested this myself yet.

This allows reboot/shutdown of the client and leaves the chia GUI running fine server-side.

1 Like

xrpa is a remote display server, so it technically runs a desktop environment which allows the GUI to run. Yeah you can totally do something like this, XRDP would do the same, but I’m not sure I see tons of value in it when you can more easily run the daemons in the background, without the need for an entirely separate display server from your normal desktop session provider.

Yeah, I worded that a bit loosely.

The main difference is that server side only the GUI application is started, not a full desktop. The application’s GUI output is redirected to the client’s desktop. So lower memory and bandwidth use.

Also the benefit of not running a dozen or so other things that are needed to support a full desktop environment (thinking about security vulnerabilities here).

1 Like

Ah yes, that will do, thanks didn’t think about that.

The reason I want to switch to Linux btw is here:

Some days, at 20:01 my system get’s fucked. I tried changing drivers , re-install, different MB but so far the problem remains. At first I didn’t notice that it occurred at the same time of the day, but now that i saw that it must be some scheduled task. I’ve tried to identify it, but so far no luck and I’m getting tired of it.
I think the day the day that Windows logs make sense to me will be the day I rule the world.