cron is not working

Any ideas??

fly.toml

app = "app"
primary_region = "nrt"
console_command = "/rails/bin/rails console"

[build]

[deploy]
  release_command = "./bin/rails db:migrate"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 1
  processes = ["web"]

[[statics]]
  guest_path = "/rails/frontend/public"
  url_prefix = "/"

[processes]
  web = "bin/rails server"
  cron = "supercronic /rails/crontab"

Dockerfile

# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.2.2
ARG NODE_VERSION=16.13.0

FROM node:$NODE_VERSION-slim as client

WORKDIR /rails/frontend

ENV NODE_ENV=production

# Install node modules
COPY frontend/package.json frontend/yarn.lock ./
RUN yarn install --frozen-lockfile

# build client application
COPY frontend .
RUN yarn generate


FROM ruby:$RUBY_VERSION-slim as base

LABEL fly_launch_runtime="rails"

# Rails app lives here
WORKDIR /rails

# Set production environment
ENV RAILS_ENV="production" \
    BUNDLE_WITHOUT="development:test" \
    BUNDLE_DEPLOYMENT="1"

# Update gems and bundler
RUN gem update --system --no-document && \
    gem install -N bundler


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build gems and node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential curl git libpq-dev node-gyp pkg-config python-is-python3

# Latest releases available at https://github.com/aptible/supercronic/releases
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.26/supercronic-linux-amd64 \
    SUPERCRONIC=supercronic-linux-amd64 \
    SUPERCRONIC_SHA1SUM=7a79496cf8ad899b99a719355d4db27422396735

RUN curl -fsSLO "$SUPERCRONIC_URL" \
 && echo "${SUPERCRONIC_SHA1SUM}  ${SUPERCRONIC}" | sha1sum -c - \
 && chmod +x "$SUPERCRONIC" \
 && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
 && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic

# You might need to change this depending on where your crontab is located
COPY crontab crontab

# Install JavaScript dependencies
ARG NODE_VERSION=16.13.0
ARG YARN_VERSION=1.22.19
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
    /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
    npm install -g yarn@$YARN_VERSION && \
    rm -rf /tmp/node-build-master

# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle install && \
    bundle exec bootsnap precompile --gemfile && \
    rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git

# Copy application code
COPY . .

# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/


# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y curl postgresql-client && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /rails /rails

# Copy built client
COPY --from=client /rails/public /rails/public

# Run and own only the runtime files as a non-root user for security
RUN useradd rails --create-home --shell /bin/bash && \
    chown -R rails:rails db log storage tmp
USER rails:rails

# Deployment options
ENV RAILS_LOG_TO_STDOUT="1" \
    RAILS_SERVE_STATIC_FILES="true"

# Entrypoint sets up the container.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000

crontab

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /rails && rails runner SendLastMonthlyReportToUser.run'

Machine information

$ fly scale show
VM Resources for app: app

Groups
NAME    COUNT   KIND    CPUS    MEMORY  REGIONS 
cron    1       shared  1       256 MB  nrt    
web     2       shared  1       512 MB  nrt(2) 

But, status of the machine for cron is stopped

I would suggest using fly logs to tail the logs of the application; you can filter by instance as well, fly logs -i <INSTANCE_IDENTIFIER> (where the instance identifier is the machine id for the cron process group, you can get it with fly machines list). Then on another terminal, fly machine restart <INSTANCE_IDENTIFIER>. When it restarts, if there’s any errors starting supercronic you will get some details as to what happened.

That said, I think the presence of ENTRYPOINT is overriding your specified command for supercronic. You may have some luck changing from ENTRYPOINT to CMD so the command can be overridden by your process group’s commands.

  • Danel
1 Like

fly logs -i

2023-09-07T23:44:11Z app[xxx] nrt [info][    0.040036] PCI: Fatal: No config space access function found
2023-09-07T23:44:11Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-07T23:44:11Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:44:11Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:44:11Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:44:11Z app[xxx] nrt [info]2023/09/07 23:44:11 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:11Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:44:12Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:44:12Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:44:12Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:44:12Z app[xxx] nrt [info]2023/09/07 23:44:12 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:13Z app[xxx] nrt [info][    2.291358] reboot: Restarting system
2023-09-07T23:44:13Z runner[xxx] nrt [info]machine did not have a restart policy, defaulting to restart
2023-09-07T23:44:13Z app[xxx] nrt [info][    0.039013] PCI: Fatal: No config space access function found
2023-09-07T23:44:13Z app[xxx] nrt [info] INFO Starting init (commit: 5293a05)...
2023-09-07T23:44:13Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:44:13Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:44:13Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:44:13Z app[xxx] nrt [info]2023/09/07 23:44:13 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:13Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:44:14Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:44:14Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:44:14Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:44:14Z app[xxx] nrt [info]2023/09/07 23:44:14 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:15Z app[xxx] nrt [info][    2.289442] reboot: Restarting system
2023-09-07T23:44:16Z runner[xxx] nrt [info]machine did not have a restart policy, defaulting to restart
2023-09-07T23:44:16Z app[xxx] nrt [info][    0.036046] PCI: Fatal: No config space access function found
2023-09-07T23:44:16Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-07T23:44:16Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:44:16Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:44:16Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:44:16Z app[xxx] nrt [info]2023/09/07 23:44:16 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:16Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:44:17Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:44:17Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:44:17Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:44:17Z app[xxx] nrt [info]2023/09/07 23:44:17 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:18Z app[xxx] nrt [info][    2.287433] reboot: Restarting system
2023-09-07T23:44:18Z runner[xxx] nrt [info]machine did not have a restart policy, defaulting to restart
2023-09-07T23:44:19Z app[xxx] nrt [info][    0.041259] PCI: Fatal: No config space access function found
2023-09-07T23:44:19Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-07T23:44:19Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:44:19Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:44:19Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:44:19Z app[xxx] nrt [info]2023/09/07 23:44:19 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:19Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:44:20Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:44:20Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:44:20Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:44:20Z app[xxx] nrt [info]2023/09/07 23:44:20 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:21Z app[xxx] nrt [info][    2.295553] reboot: Restarting system
2023-09-07T23:44:21Z runner[xxx] nrt [info]machine did not have a restart policy, defaulting to restart
2023-09-07T23:44:22Z app[xxx] nrt [info][    0.037542] PCI: Fatal: No config space access function found
2023-09-07T23:44:22Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-07T23:44:22Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:44:22Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:44:22Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:44:22Z app[xxx] nrt [info]2023/09/07 23:44:22 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:22Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:44:23Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:44:23Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:44:23Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:44:23Z app[xxx] nrt [info]2023/09/07 23:44:23 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:24Z app[xxx] nrt [info][    2.292225] reboot: Restarting system
2023-09-07T23:44:25Z runner[xxx] nrt [info]machine did not have a restart policy, defaulting to restart
2023-09-07T23:44:26Z app[xxx] nrt [info][    0.035949] PCI: Fatal: No config space access function found
2023-09-07T23:44:26Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-07T23:44:26Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:44:26Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:44:26Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:44:26Z app[xxx] nrt [info]2023/09/07 23:44:26 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:26Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:44:27Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:44:27Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:44:27Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:44:27Z app[xxx] nrt [info]2023/09/07 23:44:27 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:28Z app[xxx] nrt [info][    2.293042] reboot: Restarting system
2023-09-07T23:44:28Z runner[xxx] nrt [info]machine did not have a restart policy, defaulting to restart
2023-09-07T23:44:31Z app[xxx] nrt [info][    0.036444] PCI: Fatal: No config space access function found
2023-09-07T23:44:31Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-07T23:44:31Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:44:31Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:44:31Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:44:31Z app[xxx] nrt [info]2023/09/07 23:44:31 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:31Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:44:32Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:44:32Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:44:32Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:44:32Z app[xxx] nrt [info]2023/09/07 23:44:32 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:33Z app[xxx] nrt [info][    2.285410] reboot: Restarting system
2023-09-07T23:44:33Z runner[xxx] nrt [info]machine did not have a restart policy, defaulting to restart
2023-09-07T23:44:38Z app[xxx] nrt [info][    0.036888] PCI: Fatal: No config space access function found
2023-09-07T23:44:38Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-07T23:44:38Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:44:38Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:44:38Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:44:38Z app[xxx] nrt [info]2023/09/07 23:44:38 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:38Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:44:39Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:44:39Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:44:39Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:44:39Z app[xxx] nrt [info]2023/09/07 23:44:39 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:40Z app[xxx] nrt [info][    2.297464] reboot: Restarting system
2023-09-07T23:44:41Z runner[xxx] nrt [info]machine did not have a restart policy, defaulting to restart
2023-09-07T23:44:52Z app[xxx] nrt [info][    0.035700] PCI: Fatal: No config space access function found
2023-09-07T23:44:52Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-07T23:44:53Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:44:53Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:44:53Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:44:53Z app[xxx] nrt [info]2023/09/07 23:44:53 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:53Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:44:54Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:44:54Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:44:54Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:44:54Z app[xxx] nrt [info]2023/09/07 23:44:54 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:44:55Z app[xxx] nrt [info][    2.286372] reboot: Restarting system
2023-09-07T23:44:55Z runner[xxx] nrt [info]machine did not have a restart policy, defaulting to restart
2023-09-07T23:45:11Z app[xxx] nrt [info][    0.036692] PCI: Fatal: No config space access function found
2023-09-07T23:45:11Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-07T23:45:11Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:45:11Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:45:11Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:45:11Z app[xxx] nrt [info]2023/09/07 23:45:11 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:45:11Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:45:12Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:45:12Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:45:12Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:45:12Z app[xxx] nrt [info]2023/09/07 23:45:12 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:45:13Z app[xxx] nrt [info][    2.292211] reboot: Restarting system
2023-09-07T23:45:13Z runner[xxx] nrt [info]machine did not have a restart policy, defaulting to restart
2023-09-07T23:45:53Z app[xxx] nrt [info][    0.035741] PCI: Fatal: No config space access function found
2023-09-07T23:45:53Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-07T23:45:53Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-07T23:45:53Z app[xxx] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint supercronic /rails/crontab` as rails
2023-09-07T23:45:53Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-07T23:45:53Z app[xxx] nrt [info]2023/09/07 23:45:53 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:45:53Z app[xxx] nrt [info]/rails/bin/docker-entrypoint: line 5: exec: supercronic: not found
2023-09-07T23:45:54Z app[xxx] nrt [info] INFO Main child exited normally with code: 127
2023-09-07T23:45:54Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-07T23:45:54Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-07T23:45:54Z app[xxx] nrt [info]2023/09/07 23:45:54 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-07T23:45:55Z app[xxx] nrt [info][    2.286436] reboot: Restarting system
2023-09-07T23:45:56Z runner[xxx] nrt [info]machine has reached its max restart count (10)

modify dockerfile

-ENTRYPOINT ["/rails/bin/docker-entrypoint"]
+CMD ["/rails/bin/docker-entrypoint"]

restert server

2023-09-08T00:04:19Z app[xxx] nrt [info][    0.274512] reboot: Restarting system
2023-09-08T00:04:19Z app[xxx] nrt [warn]Virtual machine exited abruptly
2023-09-08T00:04:20Z runner[xxx] nrt [info]machine exited with exit code 0, not restarting
2023-09-08T00:14:02Z app[xxx] nrt [info][    0.035936] PCI: Fatal: No config space access function found
2023-09-08T00:14:02Z app[xxx] nrt [info] INFO Starting init (commit: 5293a085)...
2023-09-08T00:14:02Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-08T00:14:02Z app[xxx] nrt [info] INFO Preparing to run: `supercronic /rails/crontab` as rails
2023-09-08T00:14:02Z app[xxx] nrt [info]ERROR Error: failed to spawn command: supercronic /rails/crontab: No such file or directory (os error 2)
2023-09-08T00:14:02Z app[xxx] nrt [info]    does `supercronic` exist and is it executable?
2023-09-08T00:14:02Z app[xxx] nrt [info][    0.278165] reboot: Restarting system
2023-09-08T00:14:02Z app[xxx] nrt [warn]Virtual machine exited abruptly
2023-09-08T00:14:03Z runner[xxx] nrt [info]machine exited with exit code 0, not restarting

Hi!

It looks like you installed supercronic into an intermediate build step (FROM base as build) but not into the final image built that runs the app.

The supercronic stuff should be installed after:

# Final stage for app image
FROM base

It work!! Thanks!!

Apparently, to reflect cron, the fly machine must be manually restarted after deployment.

fly machine restart <INSTANCE_IDENTIFIER>

Hmmm that doesn’t sound right - do the logs show anything useful related to the CRON vm?

For example, modify it as follows.

# crontab

*/1 * * * * bundle exec rails runner AwesomeTask.run
$ fly deploy

logs

2023-09-10T11:03:09Z runner[xxx] nrt [info]Pulling container image registry.fly.io/xxx-app:deployment-xxx
2023-09-10T11:03:25Z runner[xxx] nrt [info]Successfully prepared image registry.fly.io/xxx-app:deployment-xxx (15.913440647s)
2023-09-10T11:03:25Z runner[xxx] nrt [info]Configuring firecracker
2023-09-10T11:03:26Z app[xxx] nrt [info]time="2023-09-10T11:03:26Z" level=info msg="received interrupt, shutting down"
2023-09-10T11:03:26Z app[xxx] nrt [info]time="2023-09-10T11:03:26Z" level=info msg="waiting for jobs to finish"
2023-09-10T11:03:26Z app[xxx] nrt [info]time="2023-09-10T11:03:26Z" level=info msg=exiting
2023-09-10T11:03:26Z app[xxx] nrt [info] INFO Sending signal SIGINT to main child process w/ PID 255
2023-09-10T11:03:26Z app[xxx] nrt [info] INFO Main child exited normally with code: 0
2023-09-10T11:03:26Z app[xxx] nrt [info] INFO Starting clean up.
2023-09-10T11:03:26Z app[xxx] nrt [info] WARN hallpass exited, pid: 256, status: signal: 15 (SIGTERM)
2023-09-10T11:03:26Z app[xxx] nrt [info]2023/09/10 11:03:26 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-10T11:03:27Z app[xxx] nrt [info][111675.932546] reboot: Restarting system

Cron is not working.

Then, after restart.

$ fly machine restart <INSTANCE_IDENTIFIER>

logs

2023-09-10T11:10:05Z app[xxx] nrt [info][    0.037553] PCI: Fatal: No config space access function found
2023-09-10T11:10:05Z app[xxx] nrt [info] INFO Starting init (commit: 5293b085)...
2023-09-10T11:10:05Z app[xxx] nrt [info] INFO starting statics vsock server
2023-09-10T11:10:05Z app[xxx] nrt [info] INFO Preparing to run: `supercronic /rails/crontab` as rails
2023-09-10T11:10:05Z app[xxx] nrt [info] INFO [fly api proxy] listening at /.fly/api
2023-09-10T11:10:05Z app[xxx] nrt [info]2023/09/10 11:10:05 listening on [fdaa:2:5a3e:a7b:fc:a19d:2e0b:2]:22 (DNS: [fdaa::3]:53)
2023-09-10T11:10:05Z app[xxx] nrt [info]time="2023-09-10T11:10:05Z" level=info msg="read crontab: /rails/crontab"

It works!

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