crontabdoes not exist on the service
10 months ago
I'd like to use a single service for kicking off multiple cron jobs at various days/times. I've attempted to use the whenever
gem to configure these tasks, (which are just calling very simple rake tasks that enqueue sidekiq jobs to be run on a separate worker service), but I get an error when the build runs:
/usr/local/rvm/gems/ruby-3.3.4/gems/whenever-1.0.0/lib/whenever/command_line.rb:77:in `popen': No such file or directory - /usr/bin/crontab (Errno::ENOENT)
It seems like the only solution is to create one service per cron job using the built-in cron mechanism, meaning that if I have 20 cron schedules, then I'll need to create 20 services for these. Is that correct? Why isn't crontab an option?
4 Replies
10 months ago
contab is a program / binary that isn't installed by default.
To try installing it, add this nixpacks.toml file to your project -
[phases.setup]
aptPkgs = ['...', 'cron']
10 months ago
Thank you! I'm new to nixpacks, so I was just using the Railway defaults initially. This solves the problem I asked about here. (I do have a follow-up question I'll ask in a new discussion.)
In case it helps others deploying a Rails app with multiple processes, here's the approach I took.
First, since I have 3 services (web, worker, & whenever), I created 3 toml
files:
config/railway.web.toml
[phases.setup] providers = ['...', 'ruby'] [deploy] startCommand = 'bundle exec rails db:prepare db:seed && bundle exec rails server -b 0.0.0.0 -p ${PORT:-3000} -e $RAILS_ENV'
config/railway.worker.toml
[phases.setup] providers = ['...', 'ruby'] [deploy] startCommand = 'bundle exec rails db:prepare db:seed && bundle exec sidekiq'
config/railway.whenever.toml
[phases.setup] providers = ['...', 'ruby'] aptPkgs = ['...', 'cron'] [deploy] startCommand = 'bundle exec rails db:prepare db:seed && bundle exec whenever --update-crontab'
Next, I set the NIXPACKS_CONFIG_FILE
environment variable for each of these services:
web:
NIXPACKS_CONFIG_FILE=config/railway.web.toml
worker:
NIXPACKS_CONFIG_FILE=config/railway.worker.toml
whenever:
NIXPACKS_CONFIG_FILE=config/railway.whenever.toml
I also removed any "build command" or "deploy command" settings previously assigned for these services.
Last, I removed any Procfile
and Dockerfile
files in from my repo. (I'm still seeing that my web service's startCommand
value isn't being respected while the other services are, unfortunately. I'm not sure why yet.)
10 months ago
My follow-up question is here for anyone who is interested: https://help.railway.app/questions/web-service-s-nixpack-start-command-not-02e0c92e
10 months ago
May I ask you to remove all that config you shared? as it is wrong (we can cover why in your other thread)