diff options
Diffstat (limited to 'lib/awprint/index.js')
| -rw-r--r-- | lib/awprint/index.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/awprint/index.js b/lib/awprint/index.js index dec43fd..f379ad8 100644 --- a/lib/awprint/index.js +++ b/lib/awprint/index.js @@ -4,6 +4,8 @@ var path = require('path') mongoose.Promise = require('bluebird') var socketIO = require('socket.io') +var exec = require('child_process').exec + function AWPrint (options) { if (!(this instanceof AWPrint)) return new AWPrint(options) @@ -66,10 +68,18 @@ function AWPrint (options) { router.post('/print', bodyParser.json({}), function (req, res) { res.sendStatus(200) - Print.update({ _id: req.body._id }, { printed: true, }).then( (req) => { - // send a websocket message? + Print.findOne({ _id: req.body._id }).then( (job) => { + job.printed = true + + var cmd = 'curl ' + job.url + ' | lpr -P ARMORYHPM553' + console.log(cmd) + exec(cmd, function(error, stdout, stderr) { + console.log('ok') + }) + + return job.save() }).catch( (err) => { - // idk + console.log('error saving?') }) }) |
