@nexrender/worker 1.39.7 → 1.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/readme.md +2 -0
- package/src/bin.js +28 -23
- package/src/index.js +58 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexrender/worker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.40.0",
|
|
4
4
|
"author": "inlife",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@nexrender/api": "^1.
|
|
20
|
-
"@nexrender/core": "^1.
|
|
21
|
-
"@nexrender/types": "^1.
|
|
19
|
+
"@nexrender/api": "^1.40.0",
|
|
20
|
+
"@nexrender/core": "^1.40.0",
|
|
21
|
+
"@nexrender/types": "^1.40.0",
|
|
22
22
|
"arg": "^4.1.0",
|
|
23
23
|
"chalk": "^2.4.2",
|
|
24
24
|
"rimraf": "^3.0.2"
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "9c2ab173beeed9a531a924841576ee71943817d3"
|
|
30
30
|
}
|
package/readme.md
CHANGED
|
@@ -50,6 +50,7 @@ const main = async () => {
|
|
|
50
50
|
workpath: '/Users/myname/.nexrender/',
|
|
51
51
|
binary: '/Users/mynames/Applications/aerender',
|
|
52
52
|
skipCleanup: true,
|
|
53
|
+
tagSelector: false,
|
|
53
54
|
addLicense: false,
|
|
54
55
|
debug: true,
|
|
55
56
|
actions: {
|
|
@@ -81,6 +82,7 @@ Available settings (almost same as for `nexrender-core`):
|
|
|
81
82
|
* `forceCommandLinePatch` - boolean, providing true will force patch re-installation
|
|
82
83
|
* `stopOnError` - boolean, stop the pick-up-and-render process if an error occurs (false by default)
|
|
83
84
|
* `polling` - number, amount of miliseconds to wait before checking queued projects from the api, if specified will be used instead of NEXRENDER_API_POLLING env variable
|
|
85
|
+
* `tagSelector` - string, (optional) provide the string tags (example `primary,plugins,halowell` : comma delimited) to pickup the job with specific tags. Leave it false to ignore and pick a random job from the server with no specific tags. Tags name must be an alphanumeric.
|
|
84
86
|
* `wslMap` - string, drive letter of your WSL mapping in Windows
|
|
85
87
|
* `aeParams` - array of strings, any additional params that will be passed to the aerender binary, a name-value parameter pair separated by a space,
|
|
86
88
|
* `actions` - an object with keys corresponding to the `module` field when defining an action, value should be a function matching expected signature of an action. Used for defining actions programmatically without needing to package the action as a separate package
|
package/src/bin.js
CHANGED
|
@@ -9,36 +9,38 @@ const rimraf = require('rimraf')
|
|
|
9
9
|
|
|
10
10
|
const args = arg({
|
|
11
11
|
// Types
|
|
12
|
-
'--help':
|
|
13
|
-
'--version':
|
|
14
|
-
'--cleanup':
|
|
12
|
+
'--help': Boolean,
|
|
13
|
+
'--version': Boolean,
|
|
14
|
+
'--cleanup': Boolean,
|
|
15
15
|
|
|
16
|
-
'--host':
|
|
17
|
-
'--secret':
|
|
16
|
+
'--host': String,
|
|
17
|
+
'--secret': String,
|
|
18
18
|
|
|
19
|
-
'--binary':
|
|
20
|
-
'--workpath':
|
|
21
|
-
'--wsl-map':
|
|
19
|
+
'--binary': String,
|
|
20
|
+
'--workpath': String,
|
|
21
|
+
'--wsl-map': String,
|
|
22
|
+
'--tag-selector': String,
|
|
22
23
|
|
|
23
|
-
'--stop-on-error':
|
|
24
|
+
'--stop-on-error': Boolean,
|
|
24
25
|
|
|
25
|
-
'--skip-cleanup':
|
|
26
|
-
'--skip-render':
|
|
27
|
-
'--no-license':
|
|
28
|
-
'--force-patch':
|
|
29
|
-
'--debug':
|
|
30
|
-
'--multi-frames':
|
|
31
|
-
'--multi-frames-cpu':
|
|
32
|
-
'--reuse':
|
|
26
|
+
'--skip-cleanup': Boolean,
|
|
27
|
+
'--skip-render': Boolean,
|
|
28
|
+
'--no-license': Boolean,
|
|
29
|
+
'--force-patch': Boolean,
|
|
30
|
+
'--debug': Boolean,
|
|
31
|
+
'--multi-frames': Boolean,
|
|
32
|
+
'--multi-frames-cpu': Number,
|
|
33
|
+
'--reuse': Boolean,
|
|
33
34
|
|
|
34
|
-
'--max-memory-percent':
|
|
35
|
-
'--image-cache-percent':
|
|
36
|
-
'--polling':
|
|
35
|
+
'--max-memory-percent': Number,
|
|
36
|
+
'--image-cache-percent': Number,
|
|
37
|
+
'--polling': Number,
|
|
37
38
|
|
|
38
|
-
'--aerender-parameter':
|
|
39
|
+
'--aerender-parameter': [String],
|
|
39
40
|
|
|
40
41
|
// Aliases
|
|
41
42
|
'-v': '--version',
|
|
43
|
+
'-t': '--tag-selector',
|
|
42
44
|
'-c': '--cleanup',
|
|
43
45
|
'-h': '--help',
|
|
44
46
|
'-s': '--secret',
|
|
@@ -87,11 +89,13 @@ if (args['--help']) {
|
|
|
87
89
|
-w, --workpath {underline absolute_path} manually override path to the working directory
|
|
88
90
|
by default nexrender is using os tmpdir/nexrender folder
|
|
89
91
|
|
|
90
|
-
-m, --wsl-map
|
|
92
|
+
-m, --wsl-map drive letter of your WSL mapping in Windows
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
-t, --tag-selector the string tags (comma delimited) to pickup the job with specific tag.
|
|
93
95
|
|
|
96
|
+
{bold ADVANCED OPTIONS}
|
|
94
97
|
|
|
98
|
+
|
|
95
99
|
--stop-on-error forces worker to stop if processing/rendering error occures,
|
|
96
100
|
otherwise worker will report an error, and continue working
|
|
97
101
|
|
|
@@ -188,6 +192,7 @@ opt('imageCachePercent', '--image-cache-percent');
|
|
|
188
192
|
opt('polling', '--polling');
|
|
189
193
|
opt('wslMap', '--wsl-map');
|
|
190
194
|
opt('aeParams', '--aerender-parameter');
|
|
195
|
+
opt('tagSelector', '--tag-selector');
|
|
191
196
|
|
|
192
197
|
if (args['--cleanup']) {
|
|
193
198
|
settings = init(Object.assign(settings, {
|
package/src/index.js
CHANGED
|
@@ -14,7 +14,12 @@ const delay = amount => (
|
|
|
14
14
|
const nextJob = async (client, settings) => {
|
|
15
15
|
do {
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
let job = {};
|
|
18
|
+
if(settings.tagSelector){
|
|
19
|
+
job = await client.pickupJob(settings.tagSelector);
|
|
20
|
+
}else{
|
|
21
|
+
job = await client.pickupJob();
|
|
22
|
+
}
|
|
18
23
|
|
|
19
24
|
if (job && job.uid) {
|
|
20
25
|
return job
|
|
@@ -24,6 +29,8 @@ const nextJob = async (client, settings) => {
|
|
|
24
29
|
throw err;
|
|
25
30
|
} else {
|
|
26
31
|
console.error(err)
|
|
32
|
+
console.error("render proccess stopped with error...")
|
|
33
|
+
console.error("continue listening next job...")
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
|
|
@@ -44,6 +51,10 @@ const start = async (host, secret, settings) => {
|
|
|
44
51
|
logger: console,
|
|
45
52
|
}))
|
|
46
53
|
|
|
54
|
+
if( typeof settings.tagSelector == 'string' ){
|
|
55
|
+
settings.tagSelector = settings.tagSelector.replace(/[^a-z0-9, ]/gi, '')
|
|
56
|
+
}
|
|
57
|
+
|
|
47
58
|
const client = createClient({ host, secret });
|
|
48
59
|
|
|
49
60
|
do {
|
|
@@ -66,14 +77,26 @@ const start = async (host, secret, settings) => {
|
|
|
66
77
|
/* send render progress to our server */
|
|
67
78
|
client.updateJob(job.uid, getRenderingStatus(job))
|
|
68
79
|
} catch (err) {
|
|
80
|
+
|
|
69
81
|
if (settings.stopOnError) {
|
|
70
82
|
throw err;
|
|
71
83
|
} else {
|
|
72
84
|
console.log(`[${job.uid}] error occurred: ${err.stack}`)
|
|
85
|
+
console.log(`[${job.uid}] render proccess stopped with error...`)
|
|
86
|
+
console.log(`[${job.uid}] continue listening next job...`)
|
|
73
87
|
}
|
|
74
88
|
}
|
|
75
89
|
}
|
|
76
90
|
|
|
91
|
+
job.onRenderError = function (undefined, err /* on render error */) {
|
|
92
|
+
/* set job render error to send to our server */
|
|
93
|
+
if( typeof err.toString == "function" ){
|
|
94
|
+
job.error = [err.toString()];
|
|
95
|
+
}else{
|
|
96
|
+
job.error = [err];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
77
100
|
job = await render(job, settings); {
|
|
78
101
|
job.state = 'finished';
|
|
79
102
|
job.finishedAt = new Date()
|
|
@@ -82,7 +105,35 @@ const start = async (host, secret, settings) => {
|
|
|
82
105
|
await client.updateJob(job.uid, getRenderingStatus(job))
|
|
83
106
|
} catch (err) {
|
|
84
107
|
job.state = 'error';
|
|
85
|
-
|
|
108
|
+
|
|
109
|
+
/* append existing error message with another error message */
|
|
110
|
+
if( job.hasOwnProperty("error") && job.error ) {
|
|
111
|
+
if(Array.isArray(job.error)){
|
|
112
|
+
if( typeof job.error.toString == "function" ){ /* Use toString as possible to prevent JSON stringify null return */
|
|
113
|
+
job.error = [].concat.apply(job.error,[err.toString()]);
|
|
114
|
+
}else{
|
|
115
|
+
job.error = [].concat.apply(job.error,[err]);
|
|
116
|
+
}
|
|
117
|
+
}else{
|
|
118
|
+
if( typeof job.error.toString == "function" ){ /* Use toString as possible to prevent JSON stringify null return */
|
|
119
|
+
job.error = [job.error.toString()];
|
|
120
|
+
}else{
|
|
121
|
+
job.error = [job.error];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if( typeof err.toString == "function" ){ /* Use toString as possible to prevent JSON stringify null return */
|
|
125
|
+
job.error.push(err.toString());
|
|
126
|
+
}else{
|
|
127
|
+
job.error.push(err);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}else{
|
|
131
|
+
if( typeof err.toString == "function" ){ /* Use toString as possible to prevent JSON stringify null return */
|
|
132
|
+
job.error = err.toString();
|
|
133
|
+
}else{
|
|
134
|
+
job.error = err;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
86
137
|
job.errorAt = new Date()
|
|
87
138
|
|
|
88
139
|
await client.updateJob(job.uid, getRenderingStatus(job)).catch((err) => {
|
|
@@ -90,6 +141,9 @@ const start = async (host, secret, settings) => {
|
|
|
90
141
|
throw err;
|
|
91
142
|
} else {
|
|
92
143
|
console.log(`[${job.uid}] error occurred: ${err.stack}`)
|
|
144
|
+
console.log(`[${job.uid}] render proccess stopped with error...`)
|
|
145
|
+
console.log(`[${job.uid}] continue listening next job...`)
|
|
146
|
+
|
|
93
147
|
}
|
|
94
148
|
});
|
|
95
149
|
|
|
@@ -97,6 +151,8 @@ const start = async (host, secret, settings) => {
|
|
|
97
151
|
throw err;
|
|
98
152
|
} else {
|
|
99
153
|
console.log(`[${job.uid}] error occurred: ${err.stack}`)
|
|
154
|
+
console.log(`[${job.uid}] render proccess stopped with error...`)
|
|
155
|
+
console.log(`[${job.uid}] continue listening next job...`)
|
|
100
156
|
}
|
|
101
157
|
}
|
|
102
158
|
} while (active)
|