-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsystem.coffee
37 lines (29 loc) · 1.21 KB
/
system.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
qs = require 'querystring'
request = require 'request'
{ exec } = require 'child_process'
module.exports =
say: (message, cb) ->
console.log "sending message: \n#{message}" if program.verbose
if program.nochat then return
chatURL = config.messageURL + "?" + qs.stringify({ message }).replace(/\'/g, '%27')
console.log "requesting #{chatURL}" if program.verbose
request.get chatURL, (err, response, body) ->
if not err and response.statusCode is 200
console.log "answer sent" if program.verbose
cb?()
else
console.log "erro #{[err]}"
reload: () ->
exec 'git pull', (err, stdout, stderr) ->
if err
console.log "git pull failed" if program.verbose
florinda.say "Failed to update :/"
else
console.log stdout
florinda.say stdout.trim(), ->
florinda.restart()
restart: ->
exec 'forever restart florinda.js', (err, stdout, stderr) ->
if err
console.log "Error running forever restart"
florinda.say "Aaaarrgh! I'm hurt"