Fun with recursion (Alternative title: It's turtles all the way down)

So, I just ran into a fun problem.

I’m migrating my websites from Github to a Gogs installation which resides on my own server, proxied through, you guessed it, Caddy.

I use Caddy’s git directive in order to automatically deploy my websites.

In order to serve files, Caddy first needs to clone them from their appropriate git repos. In order to access these repos, Caddy needs to be proxying the Gogs install… which it won’t start doing till it’s finished cloning the repos.

Help?

You could try this, although I’m not sure it’ll work. Start Caddy without the git directive but make sure proxying is enabled. Then restart Caddy (SIGUSR1) with the gitdirective and hopefully it will be able to still make use of the proxy. But again I’m not sure.

1 Like

Tried that, no luck.

Guess I better wait till 0.9 with graceful restarts? :stuck_out_tongue:

That’s indeed fun

2 Likes

I don’t think there will be much of a difference unfortunately (the only change to restarts in 0.9 is that they happen in-process).

… For lack of a better exclamation, bollocks.

How about two Caddy instances. One for proxying gogs which needs to be started first, then the other for git and serving your site. Ugly but should work.

This might work, except they need to bind to the same ports.

Can’t you specify an alternate port temporarily for the second instance that’s not proxying?

That’s ugly, but it just might work. I’ll give it a crack.

Me again.

It turns out that the git directive conflicts with my new Caddy deployment setup: I’m now committing each site’s Caddyfile, and importing the following glob: ./*/Caddyfile, which works awesomely for adding sites without touching the “master” Caddyfile.

However, I can no longer use the git directive to automagically keep sites up-to-date… I’m wondering if it’d be worth adding a plugin which could say “Hey, if the directory I’m currently in is already a git repository, git pull and then restart Caddy.”

Well, you can use then directive in git to send a restart signal to Caddy.

Ah, the dev themself!

Will git work when the site root is ./? As in, can it git clone on the current directory? Because if so… I’ve just solved every one of my deployment problems :smiley:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.