You are here
Task configuration
Any cloudtask configuration option that can be configured from the command line may also be configured through a template default, or by defining an environment variable.
Resolution order for options:
- command line (highest precedence)
- task-level default
- CLOUDTASK_{PARAM_NAME} environment variable (lowest precedence)
For example, if you want to configure the ec2 region worker instances are launched in, you can configure it as:
1) The --ec2-region command line option:
$ cloudtask --ec2-region ap-southeast-1
2) By defining EC2_REGION in a task template:
$ cat > foo.py << 'EOF'
from cloudtask import Task
class Foo(Task):
EC2_REGION = 'ap-southeast-1'
Foo.main()
EOF
$ chmod +x ./foo.py
$ ./foo.py
3) By setting the CLOUDTASK_EC2_REGION environment variable:
export CLOUDTASK_EC2_REGION=ap-southeast-1
Best practices for production use
For production use, it is recommended to create pre-configured task templates for routine jobs under revision control (e.g., Git repository). Task templates may inherit shared definitions such as the Hub APIKEY or the reporting hook from a common module:
$ cat > common.py << 'EOF'
from cloudtask import Task
class BaseTask(Task):
HUB_APIKEY = 'BRDUKK3WDXY3CFQ'
REPORT = 'mail: cloudtask@example.com alon@example.com liraz@example.com'
# save sessions in the local directory ratehr than
# $HOME/.cloudtask. That way we can easily track the session
# logs in Git too.
SESSIONS = 'sessions/'
EOF
$ cat > helloworld << 'EOF'
#!/usr/bin/python
from common import BaseTask
class HelloWorld(BaseTask):
COMMAND = 'echo hello world'
HelloWorld.main()
EOF
chmod +x helloworld