Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

made addition phantomjs arguments configurable through yaml file. #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Create a `config/development.yaml` or a `config/production.yaml` to override any
```yml
rasterizer:
command: phantomjs # phantomjs executable
args: '' # additional phantomjs arguments
port: 3001 # internal service port. No need to allow inbound or outbound access to this port
path: '/tmp/' # where the screenshot files are stored
viewport: '1024x600' # browser window size. Height frows according to the content
Expand All @@ -90,7 +91,7 @@ For instance, if you want to setup a proxy for phantomjs, create a `config/devel

```yml
rasterizer:
command: 'phantomjs --proxy=myproxy:1234'
args: '--proxy=myproxy:1234'
```

## Asynchronous Usage Example
Expand Down
1 change: 1 addition & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
rasterizer:
command: phantomjs # phantomjs executable
args: '' # additional phantomjs arguments
port: 3001 # internal service port. No need to allow inbound or outbound access to this port
path: '/tmp/' # where the screenshot files are stored
viewport: '1024x600' # browser window size. Height frows according to the content
Expand Down
3 changes: 2 additions & 1 deletion lib/rasterizerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var request = require('request');
*
* The constructor expects a configuration object as parameter, with these properties:
* command: Command to start a phantomjs process
* args : Additional phantomjs commandline arguments
* port: Server listerner port
* path: Destination of temporary images
* viewport: Width and height represent the viewport size (format: '1024x800')
Expand All @@ -34,7 +35,7 @@ var RasterizerService = function(config) {
}

RasterizerService.prototype.startService = function() {
var rasterizer = spawn(this.config.command, ['scripts/rasterizer.js', this.config.path, this.config.port, this.config.viewport]);
var rasterizer = spawn(this.config.command, [this.config.args, 'scripts/rasterizer.js', this.config.path, this.config.port, this.config.viewport]);
var self = this;
rasterizer.stderr.on('data', function (data) {
console.log('phantomjs error: ' + data);
Expand Down