Duplicate variables when setting up additional service for Sidekiq in a Rails project
Hey team, firstly love your work. I've searched Discord/Google/help for advice on this already but I haven't seen a conclusive answer.
I'm trying to find the optimal way of running Sidekiq in a Nixpacks build scenario.
Currently we have a start script containing:
bundle exec rails s -b 0.0.0.0 & bundle exec sidekiq
Up to August 2022 I believe that's been the recommended way to run both Rails and Sidekiq in a start script (rather than a Procfile environment).
Though now i'm reading that that's not the recommended way, and that one should have a separate service created solely for Sidekiq – makes sense. Here's the thread: https://discord.com/channels/713503345364697088/1024492237486309457/1024654301181788160
Do I then need to copy all environment variables that are in my Rails service to my Sidekiq service? I believe so, otherwise Sidekiq will be running a different environment to the Rails one. But no where I've seen mentions that and it feels important. It also means that we have a post-deploy manual task of environment variable duplication which doesn't sound optimal.
PS. You may notice looking at the project that I currently do have a Procfile but I'm proposing the above two-service solution and removing the Procfile in the process.
Thank you!
Project: 3c08e827-8d73-4a37-bbe9-9af9757bd354
Service: 959337ac-60f8-4004-9151-1b122a5e146014 Replies
Project ID:
3c08e827-8d73-4a37-bbe9-9af9757bd354,959337ac-60f8-4004-9151-1b122a5e1460
You can use project level variables
Project Settings -> Variables
Those will be shared with all services
Brilliant, thanks Cooper, let me look into that. Sounds exactly like what I'm looking for
We just rolled it out. Need to highlight it better!
I can't find that option i'm afraid. This is what I see as the options in Project Settings
hmm
Can you pair your Discord account and then type /beta?
I think it's still in the priority boarding menu
Will do, i'll revert when i've done that. Ta
https://railway.app/account
-> Discord
sg let me know! Once you do that, should show the Shared Variables tag
cool, now just refresh and it should show up (hopefully!)
Yes! Success. Thank you, i'll post in the thread if I have any hitches with this but appears to be exactly what I need
Perfecto 😄
Hey there, me again.
Something i'll run into with this second service setup is that there needs to be a deploy order. Rails needs to be built first, and then Sidekiq needs to be second on success of the first.
It's imperative it is ordered on success otherwise Sidekiq will deploy without any of the code in the concurrent Rails deploy (because Rails has a build stage it will be far slower and Sidekiq which will deploy instantly).
I see there's a thread here on syncing deploys which is what i'm looking for: https://discordapp.com/channels/713503345364697088/1038386449776656464/1038386449776656464
Just confirming that my existing method should work OK using a single service setup?
bundle exec rails s -b 0.0.0.0 & bundle exec sidekiq
I might stick with this existing method if it works until there's clarity over this deploy orderThat would work
You can also use GitHub actions to call the deploys synchronously
Railway Blog
Using Github Actions with Railway
Github Actions come with a pretty neat set of features to automate your workflows. In this post, we talk about using Github Actions to automate your deployments on Railway.
Thank you, i'll keep you posted