Skip to content

Commit

Permalink
added service file
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Feb 4, 2025
1 parent 8c12c22 commit ed38f32
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 464 deletions.
34 changes: 26 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ cmake_minimum_required(VERSION 3.21)

# set the project name
project(
alphafill
VERSION 2.2.0
LANGUAGES C CXX)
alphafill
VERSION 2.2.0
LANGUAGES C CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

Expand All @@ -38,6 +38,7 @@ include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CMakePackageConfigHelpers)
include(CMakeDependentOption)
include(GenerateExportHeader)
include(CTest)
include(FetchContent)
Expand All @@ -46,9 +47,20 @@ set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(CMAKE_VERSION GREATER_EQUAL 3.30)
cmake_policy(SET CMP0167 NEW)
endif()

# options
option(BUILD_DOCUMENTATION "Build the documentation" OFF)
option(BUILD_WEB_APPLICATION "Build the web application" OFF)

if(BUILD_WEB_APPLICATION)
cmake_dependent_option(AF_INSTALL_SYSTEMD_SCRIPT "Install systemd service file" ON "LINUX" OFF)
set(ALPHAFILL_PID "/var/run/alphafill" CACHE PATH "Location for the pid file of the running web application")
set(ALPHAFILL_EXE "${CMAKE_INSTALL_FULL_BINDIR}/alphafill")
endif()

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers"
Expand Down Expand Up @@ -107,11 +119,11 @@ set(BUILD_TESTING OFF)
find_package(cifpp 7 QUIET)

if(NOT cifpp_FOUND)
FetchContent_Declare(
cifpp
GIT_REPOSITORY https://github.com/PDB-REDO/libcifpp.git
GIT_TAG v7.0.0)
FetchContent_MakeAvailable(cifpp)
FetchContent_Declare(
cifpp
GIT_REPOSITORY https://github.com/PDB-REDO/libcifpp.git
GIT_TAG v7.0.0)
FetchContent_MakeAvailable(cifpp)

set(CIFPP_SHARE_DIR ${cifpp_SOURCE_DIR}/rsrc)
endif()
Expand Down Expand Up @@ -303,6 +315,12 @@ install(
message(NOTICE \"Please edit the ${CMAKE_INSTALL_FULL_SYSCONFDIR}/alphafill.conf file.\")
")

if(AF_INSTALL_SYSTEMD_SCRIPT)
configure_file(alphafill.service.in ${CMAKE_CURRENT_BINARY_DIR}/alphafill.service @ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/alphafill.service" DESTINATION "/etc/systemd/system")
endif()

# If we do not use resources, install the resource data in a share directory
if(NOT USE_RSRC)
install(
Expand Down
15 changes: 15 additions & 0 deletions alphafill.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=The alphafill web application
After=network.target
Wants=network-online.target

[Service]
Restart=on-failure
Type=forking
PIDFile=@ALPHAFILL_PID@
ExecStart=@ALPHAFILL_EXE@ server start
ExecReload=@ALPHAFILL_EXE@ server reload
ExecStop=@ALPHAFILL_EXE@ server stop

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions docroot/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<title>AlphaFill - Error</title>
</head>

<body>
<body class="site">
<header z2:replace="header::top('error')"></header>

<div class="container">
<div class="container site-content">

<div class="container-fluid mt-5">
<div class="alert alert-danger" role="alert">
Expand Down
11 changes: 0 additions & 11 deletions docroot/model.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,6 @@ <h5 z:text="${title}"></h5>
</tr>
</table>

<table z:if="${type=='custom'}" class="table table-sm mt-4">
<tr>
<td>Structure file</td>
<td><a z:href="@{/v1/aff/${af_id}}" z:text="${af_id}"></a></td>
</tr>
<tr>
<td>Metadata</td>
<td><a z:href="@{/v1/aff/${af_id}/json}" z:text="|${af_id}/json|"></a></td>
</tr>
</table>

<div class="row mt-5">
<div class="col" id="app"></div>

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"sass-loader": "^16.0.4",
"terser-webpack-plugin": "^5.2.5",
"ts-loader": "^9.2.6",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^5.60.0",
"webpack-cli": "^6.0.1"
},
Expand Down
54 changes: 27 additions & 27 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

const SCRIPTS = __dirname + "/webapp/";
const SCRIPTS = path.resolve(__dirname, "webapp");
const SCSS = __dirname + "/scss/";
const DEST = __dirname + "/docroot/scripts/";
const DEST = path.resolve(__dirname, "docroot");

module.exports = (env) => {

Expand All @@ -23,7 +23,8 @@ module.exports = (env) => {

output: {
path: DEST,
crossOriginLoading: 'anonymous'
crossOriginLoading: 'anonymous',
filename: "scripts/[name].js"
},

module: {
Expand All @@ -42,7 +43,7 @@ module.exports = (env) => {
{
test: /\.(sa|sc|c)ss$/i,
use: [
/* PRODUCTION ? */MiniCssExtractPlugin.loader/* : "style-loader" */,
MiniCssExtractPlugin.loader,
"css-loader",
"postcss-loader",
"sass-loader"
Expand All @@ -52,48 +53,47 @@ module.exports = (env) => {
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
include: path.resolve(__dirname, './node_modules/bootstrap-icons/font/fonts'),
type: 'asset/resource'
type: 'asset/resource',
generator: {
filename: 'fonts/[name][ext]'
}
}
]
},


resolve: {
extensions: ['.js', '.scss'],
},

optimization: { minimizer: [] },

target: 'web',

plugins: [
new MiniCssExtractPlugin({}),
new CleanWebpackPlugin({
verbose: true,
cleanOnceBeforeBuildPatterns: [
'css/**/*',
'css/*',
'scripts/**/*',
'fonts/**/*'
]
new MiniCssExtractPlugin({
filename: "css/[name].css"
})
],

optimization: {
minimizer: []
}
]
};

if (PRODUCTION) {
webpackConf.mode = "production";

// webpackConf.plugins.push(
// new CleanWebpackPlugin({
// verbose: true
// })/* ,
// new MiniCssExtractPlugin({}) */
// );
webpackConf.plugins.push(
new CleanWebpackPlugin({
verbose: true,
cleanOnceBeforeBuildPatterns: [
'css/*',
'fonts/*',
'scripts/*',
]

})
);
} else {
webpackConf.mode = "development";
webpackConf.devtool = 'source-map';
}

return webpackConf;
};

Loading

0 comments on commit ed38f32

Please sign in to comment.