From f10df39d1528a989ae89810b8cf31fd2c39d7bbb Mon Sep 17 00:00:00 2001 From: Jorge Lobo Date: Mon, 5 Jul 2021 12:47:09 +0200 Subject: [PATCH] M #~: fix webpack server kill service Signed-off-by: Jorge Lobo --- src/fireedge/src/server/index.js | 21 ++++++++-- .../src/server/routes/entrypoints/App.js | 15 +++++++ .../utils/constants/commands/vmgroup.js | 26 ++++++------ .../src/server/utils/constants/commands/vn.js | 40 +++++++++---------- .../utils/constants/commands/vntemplate.js | 30 +++++++------- .../src/server/utils/constants/defaults.js | 1 + src/fireedge/webpack.config.dev.client.js | 15 +++++++ src/fireedge/webpack.config.prod.client.js | 15 +++++++ src/fireedge/webpack.config.prod.server.js | 23 +++++++---- 9 files changed, 127 insertions(+), 59 deletions(-) diff --git a/src/fireedge/src/server/index.js b/src/fireedge/src/server/index.js index 0e9531900f..dbd2b4f798 100644 --- a/src/fireedge/src/server/index.js +++ b/src/fireedge/src/server/index.js @@ -1,3 +1,18 @@ +/* Copyright 2002-2021, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + import path from 'path' import express from 'express' import webpack from 'webpack' @@ -20,7 +35,8 @@ import { defaultHost, defaultPort, defaultWebpackMode, - defaultApps + defaultApps, + defaultEvents } from './utils/constants/defaults' import { validateServerIsSecure, @@ -177,8 +193,7 @@ function handleBreak (code) { }) } } -const eventProcess = ['SIGINT', 'SIGTERM'] -eventProcess.forEach((nameEvent = '') => { +defaultEvents.forEach((nameEvent = '') => { if (nameEvent) { process.on(nameEvent, handleBreak) } diff --git a/src/fireedge/src/server/routes/entrypoints/App.js b/src/fireedge/src/server/routes/entrypoints/App.js index f02e6085b3..264cf36604 100644 --- a/src/fireedge/src/server/routes/entrypoints/App.js +++ b/src/fireedge/src/server/routes/entrypoints/App.js @@ -1,3 +1,18 @@ +/* Copyright 2002-2021, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + const React = require('react') const { Router } = require('express') const { env } = require('process') diff --git a/src/fireedge/src/server/utils/constants/commands/vmgroup.js b/src/fireedge/src/server/utils/constants/commands/vmgroup.js index dbb0a57211..802b3c3722 100644 --- a/src/fireedge/src/server/utils/constants/commands/vmgroup.js +++ b/src/fireedge/src/server/utils/constants/commands/vmgroup.js @@ -16,18 +16,18 @@ const { from: { resource, postBody, query }, httpMethod: { GET, POST, PUT, DELETE } -} = require('../defaults'); +} = require('../defaults') -const VMGROUP_ALLOCATE = 'vmgroup.allocate'; -const VMGROUP_DELETE = 'vmgroup.delete'; -const VMGROUP_UPDATE = 'vmgroup.update'; -const VMGROUP_CHMOD = 'vmgroup.chmod'; -const VMGROUP_CHOWN = 'vmgroup.chown'; -const VMGROUP_RENAME = 'vmgroup.rename'; -const VMGROUP_INFO = 'vmgroup.info'; -const VMGROUP_LOCK = 'vmgroup.lock'; -const VMGROUP_UNLOCK = 'vmgroup.unlock'; -const VMGROUP_POOL_INFO = 'vmgrouppool.info'; +const VMGROUP_ALLOCATE = 'vmgroup.allocate' +const VMGROUP_DELETE = 'vmgroup.delete' +const VMGROUP_UPDATE = 'vmgroup.update' +const VMGROUP_CHMOD = 'vmgroup.chmod' +const VMGROUP_CHOWN = 'vmgroup.chown' +const VMGROUP_RENAME = 'vmgroup.rename' +const VMGROUP_INFO = 'vmgroup.info' +const VMGROUP_LOCK = 'vmgroup.lock' +const VMGROUP_UNLOCK = 'vmgroup.unlock' +const VMGROUP_POOL_INFO = 'vmgrouppool.info' const Actions = { VMGROUP_ALLOCATE, @@ -40,7 +40,7 @@ const Actions = { VMGROUP_LOCK, VMGROUP_UNLOCK, VMGROUP_POOL_INFO -}; +} module.exports = { Actions, @@ -218,4 +218,4 @@ module.exports = { } } } -}; +} diff --git a/src/fireedge/src/server/utils/constants/commands/vn.js b/src/fireedge/src/server/utils/constants/commands/vn.js index e245e0dab8..1d20c54be7 100644 --- a/src/fireedge/src/server/utils/constants/commands/vn.js +++ b/src/fireedge/src/server/utils/constants/commands/vn.js @@ -16,25 +16,25 @@ const { from: { resource, postBody, query }, httpMethod: { GET, POST, PUT, DELETE } -} = require('../defaults'); +} = require('../defaults') -const VN_ALLOCATE = 'vn.allocate'; -const VN_DELETE = 'vn.delete'; -const VN_AR_ADD = 'vn.add_ar'; -const VN_AR_RM = 'vn.rm_ar'; -const VN_AR_UPDATE = 'vn.update_ar'; -const VN_RESERVE = 'vn.reserve'; -const VN_AR_FREE = 'vn.free_ar'; -const VN_HOLD = 'vn.hold'; -const VN_RELEASE = 'vn.release'; -const VN_UPDATE = 'vn.update'; -const VN_CHMOD = 'vn.chmod'; -const VN_CHOWN = 'vn.chown'; -const VN_RENAME = 'vn.rename'; -const VN_INFO = 'vn.info'; -const VN_LOCK = 'vn.lock'; -const VN_UNLOCK = 'vn.unlock'; -const VN_POOL_INFO = 'vnpool.info'; +const VN_ALLOCATE = 'vn.allocate' +const VN_DELETE = 'vn.delete' +const VN_AR_ADD = 'vn.add_ar' +const VN_AR_RM = 'vn.rm_ar' +const VN_AR_UPDATE = 'vn.update_ar' +const VN_RESERVE = 'vn.reserve' +const VN_AR_FREE = 'vn.free_ar' +const VN_HOLD = 'vn.hold' +const VN_RELEASE = 'vn.release' +const VN_UPDATE = 'vn.update' +const VN_CHMOD = 'vn.chmod' +const VN_CHOWN = 'vn.chown' +const VN_RENAME = 'vn.rename' +const VN_INFO = 'vn.info' +const VN_LOCK = 'vn.lock' +const VN_UNLOCK = 'vn.unlock' +const VN_POOL_INFO = 'vnpool.info' const Actions = { VN_ALLOCATE, @@ -54,7 +54,7 @@ const Actions = { VN_LOCK, VN_UNLOCK, VN_POOL_INFO -}; +} module.exports = { Actions, @@ -334,4 +334,4 @@ module.exports = { } } } -}; +} diff --git a/src/fireedge/src/server/utils/constants/commands/vntemplate.js b/src/fireedge/src/server/utils/constants/commands/vntemplate.js index 72d9fdbc12..d96b6a2a62 100644 --- a/src/fireedge/src/server/utils/constants/commands/vntemplate.js +++ b/src/fireedge/src/server/utils/constants/commands/vntemplate.js @@ -16,20 +16,20 @@ const { from: { resource, postBody, query }, httpMethod: { GET, POST, PUT, DELETE } -} = require('../defaults'); +} = require('../defaults') -const VNTEMPLATE_ALLOCATE = 'vntemplate.allocate'; -const VNTEMPLATE_CLONE = 'vntemplate.clone'; -const VNTEMPLATE_DELETE = 'vntemplate.delete'; -const VNTEMPLATE_INSTANTIATE = 'vntemplate.instantiate'; -const VNTEMPLATE_UPDATE = 'vntemplate.update'; -const VNTEMPLATE_CHMOD = 'vntemplate.chmod'; -const VNTEMPLATE_CHOWN = 'vntemplate.chown'; -const VNTEMPLATE_RENAME = 'vntemplate.rename'; -const VNTEMPLATE_INFO = 'vntemplate.info'; -const VNTEMPLATE_LOCK = 'vntemplate.lock'; -const VNTEMPLATE_UNLOCK = 'vntemplate.unlock'; -const VNTEMPLATE_POOL_INFO = 'vntemplatepool.info'; +const VNTEMPLATE_ALLOCATE = 'vntemplate.allocate' +const VNTEMPLATE_CLONE = 'vntemplate.clone' +const VNTEMPLATE_DELETE = 'vntemplate.delete' +const VNTEMPLATE_INSTANTIATE = 'vntemplate.instantiate' +const VNTEMPLATE_UPDATE = 'vntemplate.update' +const VNTEMPLATE_CHMOD = 'vntemplate.chmod' +const VNTEMPLATE_CHOWN = 'vntemplate.chown' +const VNTEMPLATE_RENAME = 'vntemplate.rename' +const VNTEMPLATE_INFO = 'vntemplate.info' +const VNTEMPLATE_LOCK = 'vntemplate.lock' +const VNTEMPLATE_UNLOCK = 'vntemplate.unlock' +const VNTEMPLATE_POOL_INFO = 'vntemplatepool.info' const Actions = { VNTEMPLATE_ALLOCATE, @@ -44,7 +44,7 @@ const Actions = { VNTEMPLATE_LOCK, VNTEMPLATE_UNLOCK, VNTEMPLATE_POOL_INFO -}; +} module.exports = { Actions, @@ -254,4 +254,4 @@ module.exports = { } } } -}; +} diff --git a/src/fireedge/src/server/utils/constants/defaults.js b/src/fireedge/src/server/utils/constants/defaults.js index 75d95336bf..045e7bf1fa 100644 --- a/src/fireedge/src/server/utils/constants/defaults.js +++ b/src/fireedge/src/server/utils/constants/defaults.js @@ -124,6 +124,7 @@ const defaults = { defaultProtocolHotReload: 'http', defaultHost: '0.0.0.0', defaultPort: 2616, + defaultEvents: ['SIGINT', 'SIGTERM'], availableLanguages: { bg_BG: 'Bulgarian (Bulgaria)', bg: 'Bulgarian', diff --git a/src/fireedge/webpack.config.dev.client.js b/src/fireedge/webpack.config.dev.client.js index e2727c2a75..703c302eb4 100644 --- a/src/fireedge/webpack.config.dev.client.js +++ b/src/fireedge/webpack.config.dev.client.js @@ -1,3 +1,18 @@ +/* Copyright 2002-2021, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + const path = require('path') const webpack = require('webpack') const TimeFixPlugin = require('time-fix-plugin') diff --git a/src/fireedge/webpack.config.prod.client.js b/src/fireedge/webpack.config.prod.client.js index adc1f220c3..533d6f8d01 100644 --- a/src/fireedge/webpack.config.prod.client.js +++ b/src/fireedge/webpack.config.prod.client.js @@ -1,3 +1,18 @@ +/* Copyright 2002-2021, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + const path = require('path') const webpack = require('webpack') const CopyPlugin = require('copy-webpack-plugin') diff --git a/src/fireedge/webpack.config.prod.server.js b/src/fireedge/webpack.config.prod.server.js index 9434b14862..5a5d1379c6 100644 --- a/src/fireedge/webpack.config.prod.server.js +++ b/src/fireedge/webpack.config.prod.server.js @@ -1,3 +1,18 @@ +/* Copyright 2002-2021, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + const path = require('path') const webpack = require('webpack') const nodeExternals = require('webpack-node-externals') @@ -25,11 +40,6 @@ module.exports = { stats: { warnings: false }, - resolve: { - alias: { - process: 'process/browser' - } - }, plugins: [ new TimeFixPlugin(), new webpack.DefinePlugin({ @@ -37,9 +47,6 @@ module.exports = { NODE_ENV: JSON.stringify(defaultProductionWebpackMode) } }), - new webpack.ProvidePlugin({ - process: 'process/browser' - }), new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 })