nanobox-rails icon indicating copy to clipboard operation
nanobox-rails copied to clipboard

Can't set CRON Tasks

Open StarWar opened this issue 6 years ago • 0 comments

I have following boxfile.yml, and I'm not able to set CRON tasks, what should I do to see cron tasks. currently

[email protected]:~ $ sudo crontab -u gonano -l
no crontab for gonano
[email protected]:~ $ sudo crontab -l
no crontab for root

My boxfile.yaml

run.config:
  engine: ruby
  engine.config:
    runtime: ruby-2.4.2
    postgresql_client_version: "9.6"

  # add extra packages
  extra_packages:
    - nodejs
    - nginx
    - pkgconf
    - libxml2
    - libxslt
    - py36-awscli

  build_triggers:
    - Gemfile
    - Gemfile.lock

#
deploy.config:
  extra_steps:
    - rake assets:precompile RAILS_ENV=production

  before_live:
    web.main:
      - rake db:setup_or_migrate
      - bundle exec whenever --update-crontab

# add a database
data.db:
  image: nanobox/postgresql:9.6
  extra_packages:
    - py36-awscli
  config:
    extensions:
      - autoinc
      - postgis
      - hstore
      - fuzzystrmatch
      - plpgsql
      - pg_stat_statements
  cron:
    - id: backup-production-db
      schedule: '0 * * * *'
      command: |
        date=$(date -u +%Y-%m-%d.%H-%M-%S)
        (
          PGPASSWORD=${DATA_DB_PASS} pg_dump -w -Fc -O -U ${DATA_DB_USER} production |
          gzip |
          tee >(cat - >&4) |
          curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/backup-${HOSTNAME}-${date}.sql.gz -X POST -T - >&2
        ) 4>&1 |
        aws s3 cp - s3://${AWS_S3_BACKUP_BUCKET}/${APP_NAME}-backup-${HOSTNAME}-${date}.sql.gz
        curl -k -s -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/ |
        sed 's/,/\n/g' |
        grep ${HOSTNAME} |
        sort |
        head -n-${BACKUP_COUNT:-1} |
        sed 's/.*: \?"\(.*\)".*/\1/' |
        while read file
        do
          curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
          aws s3 rm s3://${AWS_S3_BACKUP_BUCKET}/${APP_NAME}-${file}
        done

# Elasticsearch
data.elasticsearch:
  image: nanobox/elasticsearch:5

# Memcached
data.memcached:
  image: nanobox/memcached:1.4
  config:
    return_error_on_memory_exhausted: false
    max_connections: 1024
    chunk_size_growth_factor: 1.25
    minimum_allocated_space: 48
    maximum_requests_per_event: 20
    disable_cas: false
    max_backlog: 1024
    binding_protocol: 'auto'

# add a web component and give it a "start" command
web.main:
  start:
    nginx: nginx -c /app/config/nginx.conf
    puma: bundle exec puma -C /app/config/puma.rb

  # add writable dirs to the web component
  writable_dirs:
    - tmp
    - log
    - db

  # the path to a logfile you want streamed to the nanobox dashboard
  log_watch:
    rails: 'log/production.log'

StarWar avatar Sep 21 '18 14:09 StarWar