Skip to content
Snippets Groups Projects
Select Git revision
  • be1b2a1c3e0418620147b89a69b6d6b610277eb1
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

server-config.ts

Blame
  • server-config.ts 2.67 KiB
    
    const Config = {
        limits: {
            /**
             * Maximum number of blocks that could be read in 1 query.
             * This is somewhat tied to the maxOutputSizeInVoxelCountByPrecisionLevel
             * in that the <maximum number of voxel> = maxRequestBlockCount * <block size>^3.
             * The default block size is 96 which corresponds to 28,311,552 voxels with 32 max blocks.
             */
            maxRequestBlockCount: 32,
    
            /**
             * The maximum fractional volume of the query box (to prevent queries that are too big).
             */
            maxFractionalBoxVolume: 1024,
    
            /**
             * What is the (approximate) maximum desired size in voxel count by precision level
             * Rule of thumb: <response gzipped size> \in [<voxel count> / 8, <voxel count> / 4];
             *
             * The maximum number of voxels is tied to maxRequestBlockCount.
             */
            maxOutputSizeInVoxelCountByPrecisionLevel: [
                0.5 * 1024 * 1024, // ~ 80*80*80
                1 * 1024 * 1024,
                2 * 1024 * 1024,
                4 * 1024 * 1024,
                8 * 1024 * 1024,
                16 * 1024 * 1024, // ~ 256*256*256
                24 * 1024 * 1024
            ]
        },
    
        /**
         * Specify the prefix of the API, i.e.
         * <host>/<apiPrefix>/<API queries>
         */
        apiPrefix: '/VolumeServer',
    
        /**
         * If not specified otherwise by the 'port' environment variable, use this port.
         */
        defaultPort: 1337,
    
        /**
         * Node (V8) sometimes exhibits GC related issues  that significantly slow down the execution
         * (https://github.com/nodejs/node/issues/8670).
         * 
         * Therefore an option is provided that automatically shuts down the server.
         * For this to work, the server must be run using a deamon (i.e. forever.js on Linux
         * or IISnode on Windows) so that the server is automatically restarted when the shutdown happens.
         */
        shutdownParams: {
            // 0 for off, server will shut down after this amount of minutes.
            timeoutMinutes: 24 * 60 /* a day */,
            // modifies the shutdown timer by +/- timeoutVarianceMinutes (to avoid multiple instances shutting at the same time)
            timeoutVarianceMinutes: 60
        },
    
        /**
         * Maps a request identifier to a filename.
         * 
         * @param source 
         *   Source of the data.
         * @param id
         *   Id provided in the request. For xray, PDB id, for emd, EMDB id number. 
         */
        mapFile(source: string, id: string) {
            switch (source.toLowerCase()) {
                case 'x-ray': return `g:/test/mdb/xray-${id.toLowerCase()}.mdb`;
                case 'emd': return `g:/test/mdb/${id.toLowerCase()}.mdb`;
                default: return void 0;
            }
        }
    }
    
    export default Config;