Advertisement
Guest User

Untitled

a guest
Nov 12th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pi@raspberrypi:~/c9sdk/configs $ cat standalone.js
  2. module.exports = function(config, optimist) {
  3.  
  4.     var path = require("path");
  5.  
  6.     if (!optimist.local) {
  7.         optimist
  8.             .boolean("t")
  9.             .describe("t", "Start in test mode")
  10.             .describe("k", "Kill tmux server in test mode")
  11.             .default("b", false)
  12.             .describe("b", "Start the bridge server - to receive commands from the cli")
  13.             .default("w", config.workspaceDir)
  14.             .describe("w", "Workspace directory")
  15.             .alias("p", "port")
  16.             .default("port", process.env.PORT || config.port)
  17.             .describe("port", "Port")
  18.             .alias("d", "debug")
  19.             .default("debug", false)
  20.             .describe("debug", "Turn debugging on")
  21.             .alias("l", "listen")
  22.             .default("listen", process.env.IP || config.host)
  23.             .describe("listen", "IP address of the server")
  24.             .boolean("help")
  25.             .describe("workspacetype", "The workspace type to use")
  26.             .alias("ws", "workspacetype")
  27.             .describe("readonly", "Run in read only mode")
  28.             .alias("ro", "readonly")
  29.             .describe("packed", "Whether to use the packed version.")
  30.             .boolean("packed")
  31.             .default("packed", config.packed)
  32.             .alias("a", "auth")
  33.             .boolean("hosted")
  34.             .describe("hosted", "Use default config of the hosted version")
  35.             .default("hosted", false)
  36.             .describe("auth", "Basic Auth username:password")
  37.             .describe("collab", "Whether to enable collab.")
  38.             .default("collab", config.collab)
  39.             .describe("cache", "use cached version of cdn files")
  40.             .default("cache", true)
  41.             .describe("setting-path", "The path to store the settings.")
  42.             .boolean("inProcessLocalFs")
  43.             .describe("inProcessLocalFs", "Whether to run localfs in same process for debugging.")
  44.             .default("inProcessLocalFs", config.inProcessLocalFs)
  45.             .boolean("useBrowserCache");
  46.     }
  47.  
  48.     var argv = optimist.argv;
  49.     if (argv.help)
  50.         return null;
  51.  
  52.     var testing = argv.t;
  53.     var baseProc = path.normalize(testing
  54.         ? __dirname + "/../plugins/c9.fs/mock"
  55.         : argv.w || (__dirname + "/../"));
  56.  
  57.     // if (testing && !argv["setting-path"])
  58.     //     argv["setting-path"] = "/tmp/.c9";
  59.  
  60.     if (baseProc != "/" && baseProc != "\\") // special case / for windows
  61.         baseProc = path.resolve(baseProc);
  62.  
  63.     process.env.BASE_PROC = baseProc;
  64.  
  65.     var port = argv.p;
  66.     var host = argv.l;
  67.     var debug = argv.d;
  68.     var readonly = argv.readonly;
  69.     var startBridge = argv.b;
  70.  
  71.     config.port = port || argv.port;
  72.     config.host = host || argv.listen;
  73.  
  74.     if (argv.collab != null)
  75.         config.collab = argv.collab;
  76.  
  77.     var workspaceType = argv.workspacetype || null;
  78.  
  79.     if (argv.hosted)
  80.         config.client_config = "default-hosted";
  81.  
  82.     config.workspaceDir = baseProc;
  83.     config.settingDir = argv["setting-path"];
  84.     config.projectName = path.basename(baseProc);
  85.     config.testing = testing;
  86.     config.debug = debug;
  87.  
  88.     if (!config.startBridge)
  89.         config.startBridge = startBridge;
  90.  
  91.     if (testing && argv.k)
  92.         require("child_process").exec("tmux -L cloud91.9 kill-server", function(){});
  93.  
  94.     var isLocalhost = host == "localhost" || host == "127.0.0.1";
  95.     if (!/:/.test(argv.auth) && !isLocalhost) {
  96.         console.log("Authentication is required when not running on localhost.");
  97.         console.log("If you would like to expose this service to other hosts or the Internet");
  98.         console.log("at large, please specify -a user:pass to set a username and password");
  99.         console.log("(or use -a : to force no login).");
  100.         console.log("Use --listen localhost to only listen on the localhost interface and");
  101.         console.log("and suppress this message.\n");
  102.         host = config.host = "127.0.0.1";
  103.     }
  104.     var auth = (argv.auth + "").split(":");
  105.     if (!auth[1] && !isLocalhost && !process.env.C9_HOSTNAME) {
  106.         console.log("Warning: running Cloud9 without using HTTP authentication.");
  107.         console.log("Run using --listen localhost instead to only expose Cloud9 to localhost,");
  108.         console.log("or use -a username:password to setup HTTP authentication\n");
  109.     }
  110.  
  111.     var plugins = [
  112.         {
  113.             packagePath: "connect-architect/connect",
  114.             port: port,
  115.             host: host,
  116.             websocket: true,
  117.             showRealIP: !config.mode
  118.         },
  119.         {
  120.             packagePath: "connect-architect/connect.basicauth",
  121.             username: auth[0],
  122.             password: auth[1]
  123.         },
  124.         {
  125.             packagePath: "connect-architect/connect.static",
  126.             prefix: "/static"
  127.         },
  128.         {
  129.             packagePath: "./c9.error/error_handler",
  130.             mode: config.mode,
  131.             scope: "standalone",
  132.             hostname: config.hostname
  133.         },
  134.         "connect-architect/connect.remote-address",
  135.         "connect-architect/connect.render",
  136.         "connect-architect/connect.render.ejs",
  137.         {
  138.             packagePath: "connect-architect/connect.redirect",
  139.             trustedDomainsRe: /.*/,
  140.         },
  141.         "connect-architect/connect.cors",
  142.         "./c9.connect.favicon/favicon",
  143.         // "./c9.logger/stdout-logger",
  144.  
  145.         "./c9.core/ext",
  146.  
  147.         {
  148.             packagePath: "./c9.ide.server/plugins",
  149.             // allow everything in standalone mode
  150.             blacklist: {
  151.                 "c9.ide.server": true,
  152.                 "c9.ide.test.selenium": true
  153.             },
  154.             whitelist: {
  155.                 "c9.core": true,
  156.                 "c9.fs": true,
  157.                 "c9.automate": true,
  158.                 "c9.login.client": true,
  159.                 "c9.vfs.client": true,
  160.                 "c9.cli.bridge": true,
  161.                 "c9.nodeapi": true,
  162.                 "saucelabs.preview": true,
  163.                 "salesforce.sync": true,
  164.                 "salesforce.language": true
  165.             }
  166.         },
  167.         "./c9.preview/statics",
  168.         "./c9.nodeapi/nodeapi",
  169.         {
  170.             packagePath: "./c9.vfs.standalone/standalone",
  171.             sdk: config.sdk,
  172.             local: config.local,
  173.             packed: argv.packed,
  174.             collab: config.collab,
  175.             version: config.cdn.version,
  176.             options: config,
  177.             installPath: config.installPath,
  178.             settingDir: config.settingDir,
  179.             correctedInstallPath: config.correctedInstallPath,
  180.             debug: debug,
  181.             workspaceDir: baseProc,
  182.             projectUrl: config.projectUrl,
  183.             homeUrl: config.homeUrl,
  184.             workspaceType: workspaceType,
  185.             readonly: readonly
  186.         },
  187.         "./c9.vfs.server/vfs.server",
  188.         "./c9.error/logger.raygun_noop",
  189.         "./c9.preview/preview.handler",
  190.         "./c9.vfs.server/cache",
  191.         "./c9.vfs.server/download",
  192.         "./c9.vfs.server/filelist",
  193.         "./c9.vfs.server/fetchcache",
  194.         "./c9.vfs.server/statics",
  195.         "./c9.analytics/mock_analytics",
  196.         "./c9.metrics/mock_metrics",
  197.         {
  198.             packagePath: "./c9.vfs.server/vfs.connect.standalone",
  199.             workspaceDir: baseProc,
  200.             readonly: readonly,
  201.             extendDirectory: config.extendDirectory,
  202.             extendOptions: config.extendOptions,
  203.             installPath: config.installPath,
  204.             settingDir: config.settingDir,
  205.             collab: config.collab,
  206.             nakBin: config.nakBin,
  207.             nodeBin: config.nodeBin,
  208.             tmuxBin: config.tmux,
  209.             vfs: {
  210.                 defaultEnv: { CUSTOM: 43 },
  211.                 local: config.local,
  212.                 debug: debug,
  213.                 inProcess: argv.inProcessLocalFs
  214.             }
  215.         /* ### BEGIN #*/
  216.         }, {
  217.             packagePath: "./c9.static/cdn",
  218.             useBrowserCache: argv.useBrowserCache,
  219.             cacheFiles: argv.cache
  220.         }, {
  221.             packagePath: "./c9.static/build",
  222.             version: config.cdn.version,
  223.             cache: config.cdn.cacheDir,
  224.             compress: config.cdn.compress,
  225.             baseUrl: config.cdn.baseUrl,
  226.             virtual: config.cdn.virtual,
  227.             config: "standalone"
  228.         /* ### END #*/
  229.         }
  230.     ];
  231.  
  232.     if (config.collab && !config.mode && !config.local) {
  233.         try {
  234.             var addApi = require("./api.standalone").addApi;
  235.         } catch(e) {}
  236.         if (addApi) {
  237.             plugins = addApi(plugins, config);
  238.         }
  239.     }
  240.  
  241.     return plugins;
  242. };
  243.  
  244. if (!module.parent) require("../server")([__filename].concat(process.argv.slice(2)));
  245. pi@raspberrypi:~/c9sdk/configs $
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement