From 56d3a832476bfda1fb7aa1df758e3d34fca1e84b Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 20 Mar 2015 15:32:28 +0000 Subject: [PATCH] Remove unused/deprecated package files and put .conf in upstart script names --- server-ce/Gruntfile.coffee | 92 +------- server-ce/package/config/settings.coffee | 219 ------------------ server-ce/package/nginx/sharelatex | 44 ---- server-ce/package/scripts/after_install.sh | 26 --- .../{sharelatex-chat => sharelatex-chat.conf} | 0 .../{sharelatex-clsi => sharelatex-clsi.conf} | 0 ...atex-docstore => sharelatex-docstore.conf} | 0 ...dater => sharelatex-document-updater.conf} | 0 ...ex-filestore => sharelatex-filestore.conf} | 0 ...ex-real-time => sharelatex-real-time.conf} | 2 +- ...atex-spelling => sharelatex-spelling.conf} | 0 .../{sharelatex-tags => sharelatex-tags.conf} | 0 ...atex-template => sharelatex-template.conf} | 0 ...-changes => sharelatex-track-changes.conf} | 0 .../{sharelatex-web => sharelatex-web.conf} | 0 15 files changed, 3 insertions(+), 380 deletions(-) delete mode 100644 server-ce/package/config/settings.coffee delete mode 100644 server-ce/package/nginx/sharelatex delete mode 100644 server-ce/package/scripts/after_install.sh rename server-ce/package/upstart/{sharelatex-chat => sharelatex-chat.conf} (100%) rename server-ce/package/upstart/{sharelatex-clsi => sharelatex-clsi.conf} (100%) rename server-ce/package/upstart/{sharelatex-docstore => sharelatex-docstore.conf} (100%) rename server-ce/package/upstart/{sharelatex-document-updater => sharelatex-document-updater.conf} (100%) rename server-ce/package/upstart/{sharelatex-filestore => sharelatex-filestore.conf} (100%) rename server-ce/package/upstart/{sharelatex-real-time => sharelatex-real-time.conf} (98%) rename server-ce/package/upstart/{sharelatex-spelling => sharelatex-spelling.conf} (100%) rename server-ce/package/upstart/{sharelatex-tags => sharelatex-tags.conf} (100%) rename server-ce/package/upstart/{sharelatex-template => sharelatex-template.conf} (100%) rename server-ce/package/upstart/{sharelatex-track-changes => sharelatex-track-changes.conf} (100%) rename server-ce/package/upstart/{sharelatex-web => sharelatex-web.conf} (100%) diff --git a/server-ce/Gruntfile.coffee b/server-ce/Gruntfile.coffee index b843b374be..d82427221c 100644 --- a/server-ce/Gruntfile.coffee +++ b/server-ce/Gruntfile.coffee @@ -161,8 +161,6 @@ module.exports = (grunt) -> Helpers.checkMake @async() grunt.registerTask "check", "Check that you have the required dependencies installed", ["check:redis", "check:latexmk", "check:s3", "check:fs", "check:aspell"] - grunt.registerTask "build:deb", "Build an installable .deb file from the current directory", () -> - Helpers.buildDeb @async() grunt.registerTask "build:upstart_scripts", "Create upstart scripts for each service", () -> Helpers.buildUpstartScripts() @@ -457,93 +455,7 @@ module.exports = (grunt) -> return callback() buildUpstartScripts: () -> - template = fs.readFileSync("package/upstart/sharelatex-template").toString() + template = fs.readFileSync("package/upstart/sharelatex-template.conf").toString() for service in SERVICES - fs.writeFileSync "package/upstart/sharelatex-#{service.name}", template.replace(/__SERVICE__/g, service.name) - - buildPackageSettingsFile: () -> - config = fs.readFileSync("config/settings.development.coffee.example").toString() - config = config.replace /DATA_DIR.*/, "DATA_DIR = '/var/lib/sharelatex/data'" - config = config.replace /TMP_DIR.*/, "TMP_DIR = '/var/lib/sharelatex/tmp'" - fs.writeFileSync "package/config/settings.coffee", config - - buildDeb: (callback = (error) ->) -> - command = ["-s", "dir", "-t", "deb", "-n", "sharelatex", "-v", "0.0.1", "--verbose"] - command.push( - "--maintainer", "ShareLaTeX " - "--config-files", "/etc/sharelatex/settings.coffee" - "--config-files", "/etc/nginx/conf.d/sharelatex.conf" - "--directories", "/var/lib/sharelatex" - "--directories", "/var/log/sharelatex" - ) - - command.push( - "--depends", "redis-server > 2.6.12" - "--depends", "mongodb-org > 2.4.0" - "--depends", "nodejs > 0.10.0" - ) - - @buildPackageSettingsFile() - - @buildUpstartScripts() - for service in SERVICES - command.push( - "--deb-upstart", "package/upstart/sharelatex-#{service.name}" - ) - - after_install_script = """ - #!/bin/sh - # Create random secret keys (twice, once for http auth pass, once for cookie secret). - sed -i "0,/CRYPTO_RANDOM/s/CRYPTO_RANDOM/$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 64 | head -n 1)/" /etc/sharelatex/settings.coffee - sed -i "0,/CRYPTO_RANDOM/s/CRYPTO_RANDOM/$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 64 | head -n 1)/" /etc/sharelatex/settings.coffee - - sudo adduser --system --group --home /var/www/sharelatex --no-create-home sharelatex - - mkdir -p /var/log/sharelatex - chown sharelatex:sharelatex /var/log/sharelatex - - mkdir -p /var/lib/sharelatex - - """ - - for dir in ["data/user_files", "tmp/uploads", "data/compiles", "data/cache", "tmp/dumpFolder"] - after_install_script += """ - mkdir -p /var/lib/sharelatex/#{dir} - - """ - - after_install_script += """ - chown -R sharelatex:sharelatex /var/lib/sharelatex - - """ - - for service in SERVICES - after_install_script += "service sharelatex-#{service.name} restart\n" - fs.writeFileSync "package/scripts/after_install.sh", after_install_script - command.push("--after-install", "package/scripts/after_install.sh") - - command.push("--exclude", "**/.git") - command.push("--exclude", "**/node_modules/grunt-*") - for path in ["filestore/user_files", "filestore/uploads", "clsi/cache", "clsi/compiles"] - command.push "--exclude", path - - for service in SERVICES - command.push "#{service.name}=/var/www/sharelatex/" - - command.push( - "package/config/settings.coffee=/etc/sharelatex/settings.coffee" - "package/nginx/sharelatex=/etc/nginx/conf.d/sharelatex.conf" - ) - console.log "fpm " + command.join(" ") - proc = spawn "fpm", command, stdio: "inherit" - proc.on "close", (code) -> - if code != 0 - callback(new Error("exit code: #{code}")) - else - callback() - - - - - + fs.writeFileSync "package/upstart/sharelatex-#{service.name}.conf", template.replace(/__SERVICE__/g, service.name) diff --git a/server-ce/package/config/settings.coffee b/server-ce/package/config/settings.coffee deleted file mode 100644 index bfefca8715..0000000000 --- a/server-ce/package/config/settings.coffee +++ /dev/null @@ -1,219 +0,0 @@ -Path = require('path') - -# These credentials are used for authenticating api requests -# between services that may need to go over public channels -httpAuthUser = "sharelatex" -httpAuthPass = "CRYPTO_RANDOM" # Randomly generated for you -httpAuthUsers = {} -httpAuthUsers[httpAuthUser] = httpAuthPass - -DATA_DIR = '/var/lib/sharelatex/data' -TMP_DIR = '/var/lib/sharelatex/tmp' - -module.exports = - # Databases - # --------- - - # ShareLaTeX's main persistant data store is MongoDB (http://www.mongodb.org/) - # Documentation about the URL connection string format can be found at: - # - # http://docs.mongodb.org/manual/reference/connection-string/ - # - # The following works out of the box with Mongo's default settings: - mongo: - url : 'mongodb://127.0.0.1/sharelatex' - - # Redis is used in ShareLaTeX for high volume queries, like real-time - # editing, and session management. - # - # The following config will work with Redis's default settings: - redis: - web: - host: "localhost" - port: "6379" - password: "" - - # The compile server (the clsi) uses a SQL database to cache files and - # meta-data. sqllite is the default, and the load is low enough that this will - # be fine in production (we use sqllite at sharelatex.com). - # - # If you want to configure a different database, see the Sequelize documentation - # for available options: - # - # https://github.com/sequelize/sequelize/wiki/API-Reference-Sequelize#example-usage - # - mysql: - clsi: - database: "clsi" - username: "clsi" - password: "" - dialect: "sqlite" - storage: Path.join(DATA_DIR, "db.sqlite") - - # File storage - # ------------ - - # ShareLaTeX can store binary files like images either locally or in Amazon - # S3. The default is locally: - filestore: - backend: "fs" - stores: - user_files: Path.join(DATA_DIR, "user_files") - - # To use Amazon S3 as a storage backend, comment out the above config, and - # uncomment the following, filling in your key, secret, and bucket name: - # - # filestore: - # backend: "s3" - # stores: - # user_files: "BUCKET_NAME" - # s3: - # key: "AWS_KEY" - # secret: "AWS_SECRET" - # - - # Local disk caching - # ------------------ - path: - # 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.join(TMP_DIR, "dumpFolder") - # Where to write uploads before they are processed - uploadFolder: Path.join(TMP_DIR, "uploads") - # Where to write the project to disk before running LaTeX on it - compilesDir: Path.join(DATA_DIR, "compiles") - # Where to cache downloaded URLs for the CLSI - clsiCacheDir: Path.join(DATA_DIR, "cache") - - # Server Config - # ------------- - - # Where your instance of ShareLaTeX can be found publicly. This is used - # when emails are sent out and in generated links: - siteUrl : 'http://localhost:3000' - - # If provided, a sessionSecret is used to sign cookies so that they cannot be - # spoofed. This is recommended. - security: - sessionSecret: "CRYPTO_RANDOM" # This was randomly generated for you - - # These credentials are used for authenticating api requests - # between services that may need to go over public channels - httpAuthUsers: httpAuthUsers - - # Should javascript assets be served minified or not. Note that you will - # need to run `grunt compile:minify` within the web-sharelatex directory - # to generate these. - useMinifiedJs: false - - # Should static assets be sent with a header to tell the browser to cache - # them. This should be false in development where changes are being made, - # but should be set to true in production. - cacheStaticAssets: false - - # If you are running ShareLaTeX over https, set this to true to send the - # cookie with a secure flag (recommended). - secureCookie: false - - # If you are running ShareLaTeX behind a proxy (like Apache, Nginx, etc) - # then set this to true to allow it to correctly detect the forwarded IP - # address and http/https protocol information. - behindProxy: false - - # Sending Email - # ------------- - # - # You must configure a mail server to be able to send invite emails from - # ShareLaTeX. The config settings are passed to nodemailer. See the nodemailer - # documentation for available options: - # - # http://www.nodemailer.com/docs/transports - # - # email: - # fromAddress: "" - # replyTo: "" - # transport: "SES" - # parameters: - # AWSAccessKeyID: "" - # AWSSecretKey: "" - - # Spell Check Languages - # --------------------- - # - # You must have the corresponding aspell dictionary installed to - # be able to use a language. Run `grunt check:aspell` to check which - # dictionaries you have installed. These should be set for the `code` for - # each language. - languages: [ - {name: "English", code: "en"} - ] - - # Service locations - # ----------------- - - # ShareLaTeX is comprised of many small services, which each expose - # an HTTP API running on a different port. Generally you - # can leave these as they are unless you have some other services - # running which conflict, or want to run the web process on port 80. - # internal: - # web: - # port: webPort = 3000 - # host: "localhost" - # documentupdater: - # port: docUpdaterPort = 3003 - # host: "localhost" - # filestore: - # port: filestorePort = 3009 - # host: "localhost" - # chat: - # port: chatPort = 3010 - # host: "localhost" - # tags: - # port: tagsPort = 3012 - # host: "localhost" - # clsi: - # port: clsiPort = 3013 - # host: "localhost" - # trackchanges: - # port: trackchangesPort = 3015 - # host: "localhost" - # docstore: - # port: docstorePort = 3016 - # host: "localhost" - # spelling: - # port: spellingPort = 3005 - # host: "localhost" - - # If you change the above config, or run some services on remote servers, - # you need to tell the other services where to find them: - apis: - web: - url: "http://localhost:3000" - user: httpAuthUser - pass: httpAuthPass - # documentupdater: - # url : "http://localhost:#{docUpdaterPort}" - # clsi: - # url: "http://localhost:#{clsiPort}" - # filestore: - # url: "http://localhost:#{filestorePort}" - # trackchanges: - # url: "http://localhost:#{trackchangesPort}" - # docstore: - # url: "http://localhost:#{docstorePort}" - # tags: - # url: "http://localhost:#{tagsPort}" - # spelling: - # url: "http://localhost:#{spellingPort}" - # chat: - # url: "http://localhost:#{chatPort}" - - -# With lots of incoming and outgoing HTTP connections to different services, -# sometimes long running, it is a good idea to increase the default number -# of sockets that Node will hold open. -http = require('http') -http.globalAgent.maxSockets = 300 -https = require('https') -https.globalAgent.maxSockets = 300 diff --git a/server-ce/package/nginx/sharelatex b/server-ce/package/nginx/sharelatex deleted file mode 100644 index 0e4fbd1c87..0000000000 --- a/server-ce/package/nginx/sharelatex +++ /dev/null @@ -1,44 +0,0 @@ -server { - listen 80; - server_name _; # Catch all, see http://nginx.org/en/docs/http/server_names.html - - set $static_path /var/www/sharelatex/web/public; - - location / { - proxy_pass http://localhost:3000; - proxy_set_header Host $http_x_forwarded_host; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_read_timeout 3m; - proxy_send_timeout 3m; - } - - location /socket.io { - proxy_pass http://localhost:3026; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header Host $http_x_forwarded_host; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_read_timeout 3m; - proxy_send_timeout 3m; - } - - location /stylesheets { - expires 1y; - root $static_path/; - } - - location /minjs { - expires 1y; - root $static_path/; - } - - location /img { - expires 1y; - root $static_path/; - } -} diff --git a/server-ce/package/scripts/after_install.sh b/server-ce/package/scripts/after_install.sh deleted file mode 100644 index 034a5bf655..0000000000 --- a/server-ce/package/scripts/after_install.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Create random secret keys (twice, once for http auth pass, once for cookie secret). -sed -i "0,/CRYPTO_RANDOM/s/CRYPTO_RANDOM/$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 64 | head -n 1)/" /etc/sharelatex/settings.coffee -sed -i "0,/CRYPTO_RANDOM/s/CRYPTO_RANDOM/$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 64 | head -n 1)/" /etc/sharelatex/settings.coffee - -sudo adduser --system --group --home /var/www/sharelatex --no-create-home sharelatex - -mkdir -p /var/log/sharelatex -chown sharelatex:sharelatex /var/log/sharelatex - -mkdir -p /var/lib/sharelatex -mkdir -p /var/lib/sharelatex/data/user_files -mkdir -p /var/lib/sharelatex/tmp/uploads -mkdir -p /var/lib/sharelatex/data/compiles -mkdir -p /var/lib/sharelatex/data/cache -mkdir -p /var/lib/sharelatex/tmp/dumpFolder -chown -R sharelatex:sharelatex /var/lib/sharelatex -service sharelatex-web restart -service sharelatex-document-updater restart -service sharelatex-clsi restart -service sharelatex-filestore restart -service sharelatex-track-changes restart -service sharelatex-docstore restart -service sharelatex-chat restart -service sharelatex-tags restart -service sharelatex-spelling restart diff --git a/server-ce/package/upstart/sharelatex-chat b/server-ce/package/upstart/sharelatex-chat.conf similarity index 100% rename from server-ce/package/upstart/sharelatex-chat rename to server-ce/package/upstart/sharelatex-chat.conf diff --git a/server-ce/package/upstart/sharelatex-clsi b/server-ce/package/upstart/sharelatex-clsi.conf similarity index 100% rename from server-ce/package/upstart/sharelatex-clsi rename to server-ce/package/upstart/sharelatex-clsi.conf diff --git a/server-ce/package/upstart/sharelatex-docstore b/server-ce/package/upstart/sharelatex-docstore.conf similarity index 100% rename from server-ce/package/upstart/sharelatex-docstore rename to server-ce/package/upstart/sharelatex-docstore.conf diff --git a/server-ce/package/upstart/sharelatex-document-updater b/server-ce/package/upstart/sharelatex-document-updater.conf similarity index 100% rename from server-ce/package/upstart/sharelatex-document-updater rename to server-ce/package/upstart/sharelatex-document-updater.conf diff --git a/server-ce/package/upstart/sharelatex-filestore b/server-ce/package/upstart/sharelatex-filestore.conf similarity index 100% rename from server-ce/package/upstart/sharelatex-filestore rename to server-ce/package/upstart/sharelatex-filestore.conf diff --git a/server-ce/package/upstart/sharelatex-real-time b/server-ce/package/upstart/sharelatex-real-time.conf similarity index 98% rename from server-ce/package/upstart/sharelatex-real-time rename to server-ce/package/upstart/sharelatex-real-time.conf index 7d44f0c8e2..df199c2d9f 100644 --- a/server-ce/package/upstart/sharelatex-real-time +++ b/server-ce/package/upstart/sharelatex-real-time.conf @@ -25,4 +25,4 @@ script echo $$ > /var/run/sharelatex-$SERVICE.pid cd /var/www/sharelatex/$SERVICE exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production PATH=$PATH:$LATEX_PATH $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1 -end script +end script \ No newline at end of file diff --git a/server-ce/package/upstart/sharelatex-spelling b/server-ce/package/upstart/sharelatex-spelling.conf similarity index 100% rename from server-ce/package/upstart/sharelatex-spelling rename to server-ce/package/upstart/sharelatex-spelling.conf diff --git a/server-ce/package/upstart/sharelatex-tags b/server-ce/package/upstart/sharelatex-tags.conf similarity index 100% rename from server-ce/package/upstart/sharelatex-tags rename to server-ce/package/upstart/sharelatex-tags.conf diff --git a/server-ce/package/upstart/sharelatex-template b/server-ce/package/upstart/sharelatex-template.conf similarity index 100% rename from server-ce/package/upstart/sharelatex-template rename to server-ce/package/upstart/sharelatex-template.conf diff --git a/server-ce/package/upstart/sharelatex-track-changes b/server-ce/package/upstart/sharelatex-track-changes.conf similarity index 100% rename from server-ce/package/upstart/sharelatex-track-changes rename to server-ce/package/upstart/sharelatex-track-changes.conf diff --git a/server-ce/package/upstart/sharelatex-web b/server-ce/package/upstart/sharelatex-web.conf similarity index 100% rename from server-ce/package/upstart/sharelatex-web rename to server-ce/package/upstart/sharelatex-web.conf