From 543c9f2878bd8fdfa1652b148c757054e5b4418f Mon Sep 17 00:00:00 2001 From: James Allen Date: Wed, 12 Feb 2014 10:21:20 +0000 Subject: [PATCH] Import web and doc updater as git repos, not npm modules --- server-ce/.gitignore | 3 + server-ce/Gruntfile.coffee | 106 ++++++++++++++---- ...ing.coffee => settings.development.coffee} | 32 ++++-- server-ce/package.json | 2 - 4 files changed, 110 insertions(+), 33 deletions(-) rename server-ce/config/{settings.testing.coffee => settings.development.coffee} (85%) diff --git a/server-ce/.gitignore b/server-ce/.gitignore index 3c3629e647..a8b670e583 100644 --- a/server-ce/.gitignore +++ b/server-ce/.gitignore @@ -1 +1,4 @@ node_modules + +web +document-updater diff --git a/server-ce/Gruntfile.coffee b/server-ce/Gruntfile.coffee index 03f7c85e04..d25f63af96 100644 --- a/server-ce/Gruntfile.coffee +++ b/server-ce/Gruntfile.coffee @@ -1,3 +1,11 @@ +fs = require "fs" +exec = require("child_process").exec +spawn = require("child_process").spawn + +WEB_REPO = "git@bitbucket.org:sharelatex/web-sharelatex.git" +DOC_UPDATER_REPO = "git@bitbucket.org:sharelatex/documentupdater-sharelatex.git" + + module.exports = (grunt) -> grunt.loadNpmTasks 'grunt-bunyan' grunt.loadNpmTasks 'grunt-execute' @@ -7,9 +15,9 @@ module.exports = (grunt) -> grunt.initConfig execute: web: - src: "node_modules/web-sharelatex/app.js" + src: "web/app.js" 'document-updater': - src: "node_modules/document-updater-sharelatex/app.js" + src: "document-updater/app.js" concurrent: all: @@ -20,25 +28,39 @@ module.exports = (grunt) -> availabletasks: tasks: options: - filter: 'exclude', - tasks: [ - 'concurrent' - 'execute' - 'bunyan' - 'availabletasks' - ] - groups: - "Run tasks": [ - "run" - "run:all" - "run:web" - "run:document-updater" - "default" - ] - "Misc": [ - "help" - ] + filter: 'exclude', + tasks: [ + 'concurrent' + 'execute' + 'bunyan' + 'availabletasks' + ] + groups: + "Run tasks": [ + "run" + "run:all" + "run:web" + "run:document-updater" + "default" + ] + "Misc": [ + "help" + ] + grunt.registerTask 'install:web', "Download and set up the web-sharelatex service", () -> + done = @async() + Helpers.installService(WEB_REPO, "web", done) + grunt.registerTask 'install:document-updater', "Download and set up the document-updater-sharelatex service", () -> + done = @async() + Helpers.installService(DOC_UPDATER_REPO, "document-updater", done) + + grunt.registerTask 'update:web', "Checkout and update the web-sharelatex service", () -> + done = @async() + Helpers.updateService("web", done) + grunt.registerTask 'update:document-updater', "Checkout and update the document-updater-sharelatex service", () -> + done = @async() + Helpers.updateService("document-updater", done) + grunt.registerTask 'help', 'Display this help list', 'availabletasks' grunt.registerTask 'run:web', "Run web-sharelatex, the ShareLaTeX web server", ["bunyan", "execute:web"] @@ -49,3 +71,47 @@ module.exports = (grunt) -> grunt.registerTask 'default', 'run' +Helpers = + installService: (repo_src, dir, callback = (error) ->) -> + Helpers.cloneGitRepo repo_src, dir, (error) -> + return callback(error) if error? + Helpers.installNpmModules dir, (error) -> + return callback(error) if error? + Helpers.runGruntInstall dir, (error) -> + return callback(error) if error? + callback() + + updateService: (dir, callback = (error) ->) -> + Helpers.updateGitRepo dir, (error) -> + return callback(error) if error? + Helpers.installNpmModules dir, (error) -> + return callback(error) if error? + Helpers.runGruntInstall dir, (error) -> + return callback(error) if error? + callback() + + cloneGitRepo: (repo_src, dir, callback = (error) ->) -> + if !fs.existsSync(dir) + proc = spawn "git", ["clone", repo_src, dir], stdio: "inherit" + proc.on "close", () -> + callback() + else + console.log "#{dir} already installed, skipping." + callback() + + updateGitRepo: (dir, callback = (error) ->) -> + proc = spawn "git", ["checkout", "master"], cwd: dir, stdio: "inherit" + proc.on "close", () -> + proc = spawn "git", ["pull"], cwd: dir, stdio: "inherit" + proc.on "close", () -> + callback() + + installNpmModules: (dir, callback = (error) ->) -> + proc = spawn "npm", ["install"], stdio: "inherit", cwd: dir + proc.on "close", () -> + callback() + + runGruntInstall: (dir, callback = (error) ->) -> + proc = spawn "grunt", ["install"], stdio: "inherit", cwd: dir + proc.on "close", () -> + callback() diff --git a/server-ce/config/settings.testing.coffee b/server-ce/config/settings.development.coffee similarity index 85% rename from server-ce/config/settings.testing.coffee rename to server-ce/config/settings.development.coffee index 8c2eb5a33d..46d8ce0da8 100644 --- a/server-ce/config/settings.testing.coffee +++ b/server-ce/config/settings.development.coffee @@ -20,7 +20,7 @@ module.exports = # ------------ # # ShareLaTeX stores binary files like images in S3. - # Fill in your Amazon S3 credential below. + # Fill in your Amazon S3 credentials below. s3: key: "" secret: "" @@ -29,7 +29,7 @@ module.exports = # Databases # --------- mongo: - url : 'mongodb://127.0.0.1/sharelatexTesting' + url : 'mongodb://127.0.0.1/sharelatex' redis: web: @@ -175,20 +175,30 @@ module.exports = # cookie with a secure flag (recommended). secureCookie: false - # Internal configs # ---------------- path: - commonFolder: Path.resolve "common" + # If we ever need to write something to disk (e.g. incoming requests + # that need processing but may be too big for memory, then write + # them to disk here). dumpFolder: Path.resolve "data/dumpFolder" - zippedProjects: Path.resolve "data/zippedProjects" - unzippedProjects: Path.resolve "data/unzippedProjects" + # Automatic Snapshots + # ------------------- automaticSnapshots: - maxTimeBetweenSnapshots: 30 * minutes + # How long should we wait after the user last edited to + # take a snapshot? waitTimeAfterLastEdit: 5 * minutes + # Even if edits are still taking place, this is maximum + # time to wait before taking another snapshot. + maxTimeBetweenSnapshots: 30 * minutes - smokeTest: - user: "team+smoketest@sharelatex.com" - password: "smoketest" - projectId: "52b18a70249683c0a9000007" + # Smoke test + # ---------- + # Provide log in credentials and a project to be able to run + # some basic smoke tests to check the core functionality. + # + # smokeTest: + # user: "" + # password: "" + # projectId: "" diff --git a/server-ce/package.json b/server-ce/package.json index 0bbfab7d78..bb2ab4e1aa 100644 --- a/server-ce/package.json +++ b/server-ce/package.json @@ -4,8 +4,6 @@ "dependencies": { "logger-sharelatex": "git+ssh://git@bitbucket.org:sharelatex/logger-sharelatex.git#bunyan", "settings-sharelatex": "git+ssh://git@bitbucket.org:sharelatex/settings-sharelatex.git#master", - "web-sharelatex": "git+ssh://git@bitbucket.org:sharelatex/web-sharelatex.git#master", - "document-updater-sharelatex": "git+ssh://git@bitbucket.org:sharelatex/documentupdater-sharelatex.git#master", "coffee-script": "~1.7.1" }, "devDependencies": {