forked from jamesyonan/brenda
-
Notifications
You must be signed in to change notification settings - Fork 2
/
brenda-node
executable file
·112 lines (103 loc) · 5.46 KB
/
brenda-node
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/python -u
# Brenda -- Blender render tool for Amazon Web Services
# Copyright (C) 2013 James Yonan <james@openvpn.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys, optparse
from brenda import config, daemon, node, version
def main():
usage = """\
usage: %s [options]
Version:
Brenda %s
Synopsis:
Render farm node worker that reads blender project, executes render tasks
from the work queue, and saves the render output in an S3 bucket.
Required config vars:
AWS_ACCESS_KEY : Amazon Web Services access key.
AWS_SECRET_KEY : Amazon Web Services secret key.
BLENDER_PROJECT : directory containing .blend file and all supporting files
for render. May be a compressed file on S3 in zip format
or any format supported by tar, i.e.
s3://BUCKET/myproject.zip, or local directory on render
farm node i.e. file:///my/local/blender/project.
May also be an EBS snapshot, i.e. ebs://snap-66c5dd62
or ebs://my-snapshot-name
WORK_QUEUE : name of SQS queue (e.g. sqs://QUEUE) containing render
work.
RENDER_OUTPUT : render farm will save render output to this S3 bucket/prefix,
e.g. s3://BUCKET or s3://BUCKET/PREFIX
Optional config vars:
S3_REGION : S3 region name, defaults to US standard.
SQS_REGION : SQS region name, defaults to US standard.
CURL_MAX_THREADS : max number of simultaneous threads to use when fetching
project bundle from S3 (default=16).
CURL_N_RETRIES : max number of retries on error when fetching project bundle
from S3 (default=4).
CURL_DEBUG : curl debug verbosity level (default=1).
VISIBILITY_TIMEOUT : SQS visibility timeout in seconds (default=120).
SQS will return a task to the queue if the node worker
doesn't acknowledge or complete the pending task over
this period of time.
VISIBILITY_TIMEOUT_REASSERT : frequency in seconds, while working on task,
that render farm will reassert with SQS that
task is still pending (default=30). This value
must be less than VISIBILITY_TIMEOUT.
N_RETRIES : number of retries on general errors before fail (default=5).
ERROR_PAUSE : number of seconds to pause after general error (default=30).
RESET_PERIOD : period of time in seconds before retry counter is reset
(default=3600).
BLENDER_PROJECT_ALWAYS_REFETCH : boolean (0|1, default=0) that indicates
whether S3-based projects should always be refetched by
the render node on startup (1), or whether the project
should be locally cached and only refetched when
modified (0).
WORK_DIR : local work directory used by render farm node, defaults to /mnt
directory.
RUNNING_ON_EC2 : boolean (0|1, default=1) that indicates if we are running
on an EC2 instance.
ADDITIONAL_EBS_0, ADDITIONAL_EBS_1, ... : Additional EBS snapshots that
were attached to the instance and should be mounted before Blender is
started. See brenda-run documentation for more info on this feature.
DONE : what to do when render job is complete, choices are:
'shutdown' -- terminate the instance
'poll' -- continue to poll the work queue for new tasks
'exit' -- exit but leave the instance running (default)""" % (sys.argv[0], version.VERSION)
parser = optparse.OptionParser(usage)
parser.add_option("-c", "--config", dest="config",
help="Configuration file (by default read from stdin)")
parser.add_option("-D", "--daemon", action="store_true", dest="daemon",
help="Run as a daemon")
parser.add_option("-l", "--log", dest="log", default="log",
help="Log to file when running as a daemon, default=%default")
parser.add_option("-p", "--pidfile", dest="pidfile", default="brenda.pid",
help="Write process ID to this file when running as a daemon, default=%default")
parser.add_option("-S", "--shutdown", action="store_true", dest="shutdown",
help="Shut down the instance on completion of all tasks")
parser.add_option("-d", "--dry-run", action="store_true", dest="dry_run",
help="Download/mount project but don't render frames")
# Get command line arguments...
( opts, args ) = parser.parse_args()
#print "OPTS", (opts, args)
# Get configuration
conf = config.Config(opts.config, 'BRENDA_', default_stdin=True)
#print "CONFIG", conf
# dispatch
func = lambda : node.run_tasks(opts, args, conf)
if opts.daemon:
i = daemon.Instance(func, opts.log, opts.pidfile)
i.start()
else:
func()
main()