-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Add worker service to serverless
- Loading branch information
Showing
10 changed files
with
489 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.git/ | ||
node_modules/ | ||
.vscode/ | ||
.nyc_output/ | ||
coverage/ | ||
.editorconfig | ||
.eslintrc.json | ||
.gitignore | ||
.travis.yml | ||
Dockerfile.* | ||
.gitattributes | ||
package-lock.json | ||
function-*/ | ||
scripts/ | ||
src/functions/azure/ | ||
!src/function/azure/workerservice.ts | ||
src/lib/microservices/ | ||
!src/lib/microservices/worker-service/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM mcr.microsoft.com/azure-functions/node:2.0 | ||
|
||
#Update ubuntu and install dependencies | ||
RUN apt-get update | ||
RUN apt-get upgrade -y | ||
RUN apt-get install -y curl apt-transport-https gnupg vim | ||
|
||
# Install nodejs | ||
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - | ||
RUN apt-get install -y nodejs build-essential | ||
|
||
# Install chrome | ||
RUN curl -sL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - | ||
RUN echo "deb https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list | ||
RUN apt-get update | ||
RUN apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst | ||
|
||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ | ||
AzureFunctionsJobHost__Logging__Console__IsEnabled=true | ||
|
||
WORKDIR /home/site/wwwroot | ||
|
||
COPY package.json /home/site/wwwroot | ||
|
||
RUN npm install | ||
|
||
# Double check you have the binaries for the Azure Service Bus extension | ||
# before create the image. | ||
COPY . /home/site/wwwroot | ||
|
||
RUN npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
{ | ||
"version": "2.0" | ||
} | ||
"version": "2.0", | ||
"extensions": { | ||
"serviceBus": { | ||
"messageHandlerOptions": { | ||
"maxAutoRenewDuration": "00:01:00", | ||
"maxConcurrentCalls": 5 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { AzureFunction, Context } from '@azure/functions'; | ||
|
||
import * as workerService from '../../lib/microservices/worker-service/worker-service'; | ||
import { IJob } from '../../lib/types'; | ||
|
||
export const run: AzureFunction = async (context: Context, job: IJob): Promise<void> => { | ||
context.log(`Start scanning: ${job.url} - Part ${job.partInfo ? job.partInfo.part : '-'} of ${job.partInfo ? job.partInfo.totalParts : '-'}`); | ||
await workerService.run(job); | ||
context.log(`Scan end for: ${job.url}`); | ||
context.done(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.