I’ve finally resolved my issue from my last post and got cloudflared to run and make the tunnel.
The good news is when I run cloudflared tunnel run projects, my tunnel starts and I am able to get to the page through my browser. Hooray!
However, once I install it as a service, everything breaks down. I think the cause of the problem is that when starting the tunnel, it uses the config in /etc/cloudflared to launch the tunnel. Assuming it tries to find the file in the same directory, it’s missing. I copied the credentials file from ~/.cloudflared to /etc/cloudflared and it works when manually running it…
When I try starting the service, it crashes. systemctl status cloudflared gives me this:
● cloudflared.service - Argo Tunnel
Loaded: loaded (/etc/systemd/system/cloudflared.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2020-12-03 16:20:01 UTC; 1s ago
Process: 3812 ExecStart=/usr/local/bin/cloudflared --config /etc/cloudflared/config.yml --no-autoupdate tunnel run (code=exited, status=1/FAILURE)
Main PID: 3812 (code=exited, status=1/FAILURE)
I am running Ubuntu Server 20.04 LTS on Arm32. This is running on a Raspberry Pi.
I guess that’ll have to do for now… The only problem is that I have to run this every time the pi goes down, which I’m not entirely sure how stable everything is going to be (“everything” includes the electrical grid, too)
You can also set up multiple crons. Actually the script just restarts the process if the service is not already running.
For ASAP retriggering the script after reboot I would recommend:
@reboot /root/tunnel.sh > /dev/null 2>&1
additionally you can set a recurring cron to restart the service if it would crash/go down. See: @reboot, which is something similar to “Autostart” at Windows.
You can go with soemthing what @sdayman wrote:
* * * * * /root/tunnel.sh > /dev/null 2>&1
As it anyway would check if the service is already running, due to:
Ok, this doesn’t solve the issue on having to move the credentials file around every time I reboot… I have to copy the file from ~/.cloudflared to /etc/cloudflared every time I reboot or the whole thing breaks…
Strange. If it works when you do it manually it should also work when doing it automized with a script.
You can chain commands with && to make sure the next command is just getting executed after the first one finished successfull.
What is the output/log of the command/script?