-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
65 lines (51 loc) · 1.68 KB
/
Gruntfile.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
module.exports = (grunt) ->
# Do grunt-related things in here
grunt.loadNpmTasks('grunt-shipit')
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
shipit:
options:
workspace: '.tmp',
deployTo: '/home/scrodde/apps/highscore-server',
repositoryUrl: 'https://github.com/scrodde/highscore-server',
ignores: ['.git', 'node_modules', 'db'],
keepReleases: 5
staging:
servers: '[email protected]'
})
grunt.registerTask('setup', ->
done = @async()
grunt.shipit.remote("mkdir -p #{grunt.shipit.config.deployTo}/shared/db", (err) ->
return done(err) if err
grunt.log.oklns('Shared database folder created.')
done()
)
)
grunt.registerTask('start', ->
done = @async()
currentPath = "#{grunt.shipit.config.deployTo}/current"
grunt.shipit.remote("cd #{currentPath} && npm start", done)
)
grunt.registerTask('stop', ->
done = @async()
currentPath = "#{grunt.shipit.config.deployTo}/current"
grunt.shipit.remote("cd #{currentPath} && npm stop", done)
)
grunt.registerTask('symlink', ->
done = @async()
currentPath = grunt.shipit.releasePath
dbPath = "#{grunt.shipit.config.deployTo}/shared/db"
grunt.shipit.remote("cd #{currentPath} && ln -s #{dbPath} db", (err) ->
return done(err) if err
grunt.log.oklns('Symlinked database folder to shared.')
done()
)
)
grunt.registerTask('migrate', ->
done = @async()
currentPath = grunt.shipit.releasePath
grunt.shipit.remote("cd #{currentPath} && npm install && knex migrate:latest", done)
)
grunt.shipit.on('updated', ->
grunt.task.run(['symlink', 'migrate'])
)