When your app is deployed on our infrastructure, the
Procfile of your project
is analyzed and the different way to start your project are registered and are
available for scaling in your dashboard.
For various reasons you may need to run other tasks in the environment of your application (a database migration, Rails console, rake tasks, etc.).
The feature requires your workstation to allow connections to the TCP port 5000. Otherwise you will experience timeouts during the connection attempts.
Run a Detached One-Off
By default one-off containers are started as attached command, it means it will only get started when a terminal interactively connect to it through the one-off endpoint. Once attached, data should be sent to the one-off or from it, otherwise the connection will be automatically closed after 30 minutes and the container will be stopped. For long interactive jobs, make sure the process is writing something to stdout or stderr.
--detached option is set, the container will be started as a
background one-off container. In this case the container is started instantly,
logs from the job are aggregated to the total logs of the application. You have
to make sure this job ends at some point.
To achieve those operations you have to use the command
run of our command
line tool which will launch a
Tasks can be interactive (like bash) or non-interactive (like rake task or shell command like ls -l).
A one-off container is a copy of your production environment. After the execution of the task, the environment is destroyed. Thus, do not expect any created file to show up in your production environment. The production environment is immutable.
$ scalingo --app my-app run ls app bin config config.ru db Gemfile Gemfile.lock lib log Procfile public Rakefile test tmp vendor
Don’t forget to quote command argument:
$ scalingo --app my-app run 'ls -l' total 40 drwxrwxr-x 1 appsdeck appsdeck 84 Sep 23 07:42 app drwxrwxr-x 1 appsdeck appsdeck 114 Sep 23 07:42 bin drwxrwxr-x 1 appsdeck appsdeck 226 Sep 23 07:42 config -rw-rw-r-- 1 appsdeck appsdeck 154 Sep 23 07:42 config.ru drwxrwxr-x 1 appsdeck appsdeck 48 Sep 23 07:42 db -rw-rw-r-- 1 appsdeck appsdeck 2208 Sep 23 07:42 Gemfile -rw-rw-r-- 1 appsdeck appsdeck 11085 Sep 23 07:42 Gemfile.lock drwxrwxr-x 1 appsdeck appsdeck 40 Sep 23 07:42 lib drwxrwxr-x 1 appsdeck appsdeck 38 Sep 23 07:42 log -rw-rw-r-- 1 appsdeck appsdeck 137 Sep 23 07:42 Procfile drwxrwxr-x 1 appsdeck appsdeck 220 Sep 23 07:42 public -rw-rw-r-- 1 appsdeck appsdeck 249 Sep 23 07:42 Rakefile drwxrwxr-x 1 appsdeck appsdeck 128 Sep 23 07:42 test drwxrwxr-x 1 appsdeck appsdeck 76 Sep 23 07:43 tmp drwxrwxr-x 1 appsdeck appsdeck 56 Nov 13 2014 vendor
$ scalingo --app my-app run bash [10:45] Scalingo ~ $ ls bin Godeps main.go Procfile README.md templates
bash with custom environment variables
$ scalingo --app my-app run --env VAR1=VAL1 --env VAR2=VAL2 bash [10:51] Scalingo ~ $ env | grep VAR VAR1=VAL1 VAR2=VAL2
Upload an archive and extract it on the server
- Use the
--fileflag to select the files to upload
$ scalingo --app my-app run --file ./dump.tar bash Upload /tmp/job-file635294589/dump.tar to container.
- Uploaded files are located in the directory
[10:51] Scalingo ~ $ ls /tmp/uploads dump.tar
- Extract the archive to
[10:51] Scalingo ~ $ tar -C /tmp -xvf /tmp/uploads/dump.tar /tmp/dump /tmp/dump/collection1.bson /tmp/dump/collection1.metadata.json /tmp/dump/collection2.bson /tmp/dump/collection2.metadata.json /tmp/dump/system.indexes.bson /tmp/dump/system.users.bson /tmp/dump/system.users.metadata.json
- Use these files with a script
[10:51] Scalingo ~ $ /app/script.sh /tmp/dump/*.json