Skip to content

Commit

Permalink
Add option to specify group ID
Browse files Browse the repository at this point in the history
  • Loading branch information
jakepruitt committed Jun 12, 2018
1 parent d2a0c28 commit f5a62b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const pkg = require(path.resolve(__dirname, '..', 'package.json'));
* of 1-minute periods before an alarm is triggered. The default is 1 period, or
* 1 minute. This parameter can be provided as either a number or a reference,
* i.e. `{"Ref": "..."}`.
* @param {Number|ref} [options.gid] - Use this group ID for the worker child process.
*/
module.exports = (options = {}) => {
['service', 'serviceVersion', 'command', 'cluster'].forEach((required) => {
Expand Down Expand Up @@ -133,7 +134,8 @@ module.exports = (options = {}) => {
[
{ Name: 'WorkTopic', Value: cf.ref(prefixed('Topic')) },
{ Name: 'QueueUrl', Value: cf.ref(prefixed('Queue')) },
{ Name: 'Volumes', Value: mountPoints.map((m) => m.ContainerPath).join(',') }
{ Name: 'Volumes', Value: mountPoints.map((m) => m.ContainerPath).join(',') },
{ Name: 'GroupID', Value: options.gid || '' }
]
);
};
Expand Down
2 changes: 2 additions & 0 deletions lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class Worker {
// An arbitrarily chosen UID of a non-existent user
uid: 200
};
// If group id is specified, add the group id
if (process.env.GroupID) options.gid = Number(process.env.GroupID);

try {
const results = await child(this.command, options, this.logger);
Expand Down

0 comments on commit f5a62b6

Please sign in to comment.