From 81759c88343c5e3715696492564b8f84566a0b85 Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Sun, 12 May 2024 12:45:28 +0200 Subject: [PATCH 1/4] Static linking: install ocsigen-start.server.a --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 7ab11e52..30f3e977 100644 --- a/Makefile +++ b/Makefile @@ -174,6 +174,7 @@ install: all META cp $(SERVER_CMI) $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server cp $(SERVER_CMX) $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server cp $(LIBDIR)/$(PKG_NAME).client.cma $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/client + cp $(LIBDIR)/$(PKG_NAME).server.a $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server cp $(LIBDIR)/$(PKG_NAME).server.cm* $(OCAMLFIND_DESTDIR)/$(PKG_NAME)/server scripts/install.sh $(TEMPLATE_DIR) $(TEMPLATE_NAME) From 3cea91ae9c09e3e7fed429dd48af972b5a27a5c6 Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Mon, 26 Aug 2024 16:16:48 +0200 Subject: [PATCH 2/4] Update template-distillery to match last version of github.com/ocsigen/os_template --- template.distillery/.gitignore | 4 +- template.distillery/Makefile.options | 4 - template.distillery/Makefile.os | 27 ++- template.distillery/Makefile.style | 2 +- template.distillery/PROJECT_NAME.conf.in | 6 +- template.distillery/PROJECT_NAME.eliom | 4 +- template.distillery/PROJECT_NAME.opam | 6 +- template.distillery/PROJECT_NAME_base.eliom | 1 + template.distillery/PROJECT_NAME_config.eliom | 4 +- template.distillery/PROJECT_NAME_main.eliom | 9 + template.distillery/PROJECT_NAME_mobile.eliom | 6 - .../PROJECT_NAME_static_config.eliom.in | 31 +++ template.distillery/README.md | 26 ++- template.distillery/client!dune | 18 -- template.distillery/dune | 193 +++++++++++++++--- template.distillery/dune-project | 2 +- template.distillery/dune.config | 10 + template.distillery/static!images!ocsigen.png | Bin 118327 -> 118328 bytes template.distillery/tools!gen_dune.ml | 2 +- template.distillery/upgrade.sql | 34 --- 20 files changed, 269 insertions(+), 120 deletions(-) create mode 100644 template.distillery/PROJECT_NAME_main.eliom create mode 100644 template.distillery/PROJECT_NAME_static_config.eliom.in delete mode 100644 template.distillery/client!dune create mode 100644 template.distillery/dune.config delete mode 100644 template.distillery/upgrade.sql diff --git a/template.distillery/.gitignore b/template.distillery/.gitignore index 577e0811..a02d0438 100644 --- a/template.distillery/.gitignore +++ b/template.distillery/.gitignore @@ -16,8 +16,8 @@ cordova # Style .sass-cache -static/css/%%%PROJECT_NAME%%%.css.map -static/css/%%%PROJECT_NAME%%%.css +static/css/project_name.css.map +static/css/project_name.css # Dune _build diff --git a/template.distillery/Makefile.options b/template.distillery/Makefile.options index 72a9733f..03c5de8a 100644 --- a/template.distillery/Makefile.options +++ b/template.distillery/Makefile.options @@ -26,10 +26,6 @@ USE_NPM := yes ##---------------------------------------------------------------------- ## The following part contains the configuration for the ocsigenserver. -# User to run server with (make run.*) -WWWUSER := www-data -WWWGROUP := www-data - # Port for running the server (make run.*) PORT := 80 diff --git a/template.distillery/Makefile.os b/template.distillery/Makefile.os index 84406abc..9fa8859b 100644 --- a/template.distillery/Makefile.os +++ b/template.distillery/Makefile.os @@ -56,12 +56,28 @@ test.opt:: opt | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles @echo "==== The website is available at http://localhost:$(TEST_PORT) ====" $(OCSIGENSERVER.OPT) $(RUN_DEBUG) -c $(patsubst %.conf.in,$(TEST_PREFIX)$(ETCDIR)/%-test.conf,$(CONF_IN)) +test.static.byte: static.byte | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles + @echo "==== The website is available at http://localhost:$(TEST_PORT) ====" + dune exec ./%%%PROJECT_NAME%%%_main.bc +test.static.opt: static.opt | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles + @echo "==== The website is available at http://localhost:$(TEST_PORT) ====" + dune exec ./%%%PROJECT_NAME%%%_main.exe + $(addprefix $(TEST_PREFIX), $(DIST_DIRS)): mkdir -p $@ staticfiles: cp -rf $(LOCAL_STATIC_CSS) $(LOCAL_STATIC_IMAGES) $(LOCAL_STATIC_FONTS) $(TEST_PREFIX)$(ELIOMSTATICDIR) +##---------------------------------------------------------------------- +## Static executable + +static.byte: byte + dune build %%%PROJECT_NAME%%%_main.bc + +static.opt: opt + dune build %%%PROJECT_NAME%%%_main.exe + ##---------------------------------------------------------------------- ## Installing & Running @@ -155,7 +171,7 @@ $(TEST_CONFIG_FILES): $(TEST_PREFIX)$(ETCDIR)/%-test.conf: %.conf.in $(JS_AND_CS ##---------------------------------------------------------------------- ## Compilation -.PHONY: gen-dune config-files +.PHONY: config-files config-files: | $(TEST_PREFIX)$(ELIOMSTATICDIR) $(TEST_PREFIX)$(LIBDIR) HASH=`md5sum _build/default/client/$(PROJECT_NAME).bc.js | cut -d ' ' -f 1` && \ @@ -164,20 +180,17 @@ config-files: | $(TEST_PREFIX)$(ELIOMSTATICDIR) $(TEST_PREFIX)$(LIBDIR) cp -f _build/default/$(PROJECT_NAME).cm* $(TEST_PREFIX)$(LIBDIR)/ $(MAKE) $(CONFIG_FILES) $(TEST_CONFIG_FILES) PROJECT_NAME=$(PROJECT_NAME) -all:: gen-dune +all:: $(ENV_PSQL) dune build $(DUNE_OPTIONS) @install @$(PROJECT_NAME) $(PROJECT_NAME).cmxs -byte:: gen-dune +byte:: $(ENV_PSQL) dune build $(DUNE_OPTIONS) @$(PROJECT_NAME) make config-files PROJECT_NAME=$(PROJECT_NAME) -opt:: gen-dune +opt:: $(ENV_PSQL) dune build $(DUNE_OPTIONS) $(PROJECT_NAME).cmxs @$(PROJECT_NAME) make config-files PROJECT_NAME=$(PROJECT_NAME) -gen-dune: - @ocaml tools/gen_dune.ml > client/dune.client - ##---------------------------------------------------------------------- ##---------------------------------------------------------------------- diff --git a/template.distillery/Makefile.style b/template.distillery/Makefile.style index e2f08727..bdd7b9b3 100644 --- a/template.distillery/Makefile.style +++ b/template.distillery/Makefile.style @@ -71,7 +71,7 @@ ifeq ($(shell which sassc),) [ -d $(SASSDIR) ] && \ SASS_PATH=$(SASS_PATH) sass --style compressed $(SASS_SRC) $@ else - [ -d $(SASSDIR) ] && \ + [ -d $(SASSDIR) ] && sassc -t compressed $(addprefix -I ,$(subst :, ,$(SASS_PATH))) $(SASS_SRC) $@ endif $(POSTCSS) --use autoprefixer --replace $@ diff --git a/template.distillery/PROJECT_NAME.conf.in b/template.distillery/PROJECT_NAME.conf.in index 06b2019a..7ceaffc4 100644 --- a/template.distillery/PROJECT_NAME.conf.in +++ b/template.distillery/PROJECT_NAME.conf.in @@ -21,18 +21,18 @@ - + = "10.0.0" & < "11.0.0"} - "ocsipersist-pgsql" {>= "1.0" & < "2.0"} - "ocsigen-start" + "eliom" {>= "11.0.0" & < "12.0.0"} + "ocsipersist-pgsql-config" {>= "2.0" & < "3.0"} + "ocsigen-start" {>= "7.0.0" & < "8.0.0"} ] diff --git a/template.distillery/PROJECT_NAME_base.eliom b/template.distillery/PROJECT_NAME_base.eliom index 60d28cfc..d4476dc1 100644 --- a/template.distillery/PROJECT_NAME_base.eliom +++ b/template.distillery/PROJECT_NAME_base.eliom @@ -1,6 +1,7 @@ (* This file was generated by Ocsigen Start. Feel free to use it, modify it, and redistribute it as you wish. *) +let%server () = %%%MODULE_NAME%%%_static_config.set_static_config () let%server application_name = !%%%MODULE_NAME%%%_config.app_name let%client application_name = Eliom_client.get_application_name () let%shared displayed_app_name = "%%%PROJECT_NAME%%%" diff --git a/template.distillery/PROJECT_NAME_config.eliom b/template.distillery/PROJECT_NAME_config.eliom index b958b3c6..77908c94 100644 --- a/template.distillery/PROJECT_NAME_config.eliom +++ b/template.distillery/PROJECT_NAME_config.eliom @@ -70,4 +70,6 @@ let os_db = in element ~name:"os-db" ~attributes () -let _ = Eliom_config.parse_config [app; avatars; os_db] +let _ = + if Ocsigen_config.has_configuration_file () + then Eliom_config.parse_config [app; avatars; os_db] diff --git a/template.distillery/PROJECT_NAME_main.eliom b/template.distillery/PROJECT_NAME_main.eliom new file mode 100644 index 00000000..4bfec9ca --- /dev/null +++ b/template.distillery/PROJECT_NAME_main.eliom @@ -0,0 +1,9 @@ +(** This is the main file if you are using static linking without config file. + It is not used if you are using a config file and ocsigenserver *) + +module%shared %%%MODULE_NAME%%% = %%%MODULE_NAME%%% + +let%server _ = + Ocsigen_server.start + [ Ocsigen_server.host + [Staticmod.run ~dir:"local/var/www/%%%PROJECT_NAME%%%" (); Eliom.run ()] ] diff --git a/template.distillery/PROJECT_NAME_mobile.eliom b/template.distillery/PROJECT_NAME_mobile.eliom index ca2161f3..c4951487 100644 --- a/template.distillery/PROJECT_NAME_mobile.eliom +++ b/template.distillery/PROJECT_NAME_mobile.eliom @@ -3,12 +3,6 @@ [%%client.start] -[@@@ocaml.warning "-33"] - -open %%%MODULE_NAME%%% (* for dependency reasons *) - -[@@@ocaml.warning "+33"] - [%%client open Js_of_ocaml] [%%client open Js_of_ocaml_lwt] diff --git a/template.distillery/PROJECT_NAME_static_config.eliom.in b/template.distillery/PROJECT_NAME_static_config.eliom.in new file mode 100644 index 00000000..206cc258 --- /dev/null +++ b/template.distillery/PROJECT_NAME_static_config.eliom.in @@ -0,0 +1,31 @@ +(* Set static configuration in case you are using static linking only. + These information are taken from the config file otherwise. +*) +let%server set_static_config () = + if not (Ocsigen_config.has_configuration_file ()) + then begin + Ocsigen_config.set_ports [`All, 8080]; + Ocsigen_config.set_veryverbose (); + Ocsigen_config.set_debugmode true; + Ocsigen_config.set_logdir "local/var/log/%%%PROJECT_NAME%%%"; + Ocsigen_config.set_datadir "local/var/data/%%%PROJECT_NAME%%%"; + Ocsigen_config.set_uploaddir (Some "/tmp"); + Ocsigen_config.set_usedefaulthostname true; + Ocsigen_config.set_command_pipe "local/var/run/%%%PROJECT_NAME%%%-cmd"; + Ocsigen_config.set_default_charset (Some "utf-8"); + Ocsipersist_settings.set_host "%%PGHOST%%"; + Ocsipersist_settings.set_port %%PGPORT%%; + Ocsipersist_settings.set_database "ocsipersist_%%%PROJECT_NAME%%%"; + Ocsipersist.init (); + %%%MODULE_NAME%%%_config.os_db_database := Some "%%PGDATABASE%%"; + %%%MODULE_NAME%%%_config.os_db_host := Some "%%PGHOST%%"; + %%%MODULE_NAME%%%_config.os_db_user := + (let u = "%%PGUSER%%" in if u = "" then None else Some u); + %%%MODULE_NAME%%%_config.os_db_password := Some "%%PGPASSWORD%%"; + %%%MODULE_NAME%%%_config.os_db_port := Some %%PGPORT%%; + %%%MODULE_NAME%%%_config.app_name := + Filename.chop_suffix + (Unix.readlink "local/var/www/%%%PROJECT_NAME%%%/%%%PROJECT_NAME%%%.js") ".js" ; + %%%MODULE_NAME%%%_config.css_name := + Unix.readlink "local/var/www/%%%PROJECT_NAME%%%/css/%%%PROJECT_NAME%%%.css"; + end diff --git a/template.distillery/README.md b/template.distillery/README.md index b87763de..c4eb3702 100644 --- a/template.distillery/README.md +++ b/template.distillery/README.md @@ -23,14 +23,22 @@ you can try updating it with `sudo npm install -g npm`. Depending on your setup, you may have to update your `$PATH` for the new `npm` to become visible. -Generally, you can compile it and run ocsigenserver on it by - +First create a local database: ```shell make db-init make db-create make db-schema +``` +Then compile and run the app, either as a library loaded dynamically +into ocsigenserver using a configuration file: +```shell make test.byte (or test.opt) ``` +or as an OCaml executable, using ocsigenserver as a libary +(without configuration file): +```shell +make test.static.byte (or test.static.opt) +``` Then connect to `http://localhost:8080` to see the running app skeleton. Registration will work only if sendmail if configured on your system. @@ -95,27 +103,33 @@ make db-status ``` - Test your application by compiling it and running ocsigenserver locally +with a configuration file: ``` make test.byte (or test.opt) ``` +- Test your application by compiling it as an OCaml executable without +configuration file: +``` +make test.static.byte (or test.static.opt) +``` + - Compile it only ```Shell make all (or byte or opt) ``` -- Deploy your project on your system +- DEPRECATED Deploy your project on your system ```Shell sudo make install (or install.byte or install.opt) ``` -- Run the server on the deployed project +- DEPRECATED Run the server on the deployed project ```Shell sudo make run.byte (or run.opt) ``` -If `WWWUSER` in the `Makefile.options` is you, you don't need the -`sudo`. If Eliom isn't installed globally, however, you need to +If Eliom isn't installed globally, however, you need to re-export some environment variables to make this work: ```Shell sudo PATH=$PATH OCAMLPATH=$OCAMLPATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH make run.byte/run.opt diff --git a/template.distillery/client!dune b/template.distillery/client!dune deleted file mode 100644 index 612407b5..00000000 --- a/template.distillery/client!dune +++ /dev/null @@ -1,18 +0,0 @@ -(executables - (names %%%PROJECT_NAME%%%) - (modes js byte) - (preprocess - (pps - js_of_ocaml-ppx - lwt_ppx - ocsigen-i18n - -- --prefix %%%MODULE_NAME%%%_ --suffix _i18n --default-module %%%MODULE_NAME%%%_i18n - ) - ) - (js_of_ocaml - (build_runtime_flags :standard --enable use-js-string) - (flags :standard --enable with-js-error --enable use-js-string - --no-source-map)) ; source maps are slow... - (libraries eliom.client ocsigen-start.client)) - -(include dune.client) diff --git a/template.distillery/dune b/template.distillery/dune index b8371242..9754b22b 100644 --- a/template.distillery/dune +++ b/template.distillery/dune @@ -1,38 +1,167 @@ -(dirs tools client assets) +(include dune.config) + +(dirs tools client gen assets static local) + +(library + (name %%%PROJECT_NAME%%%) + (modules + (:standard \ %%%MODULE_NAME%%%_main)) + (libraries eliom.server ocsigen-start.server ocsipersist-pgsql ocsipersist-pgsql.settings) + (library_flags + (:standard -linkall)) + (wrapped false) + (preprocess + (pps + lwt_ppx + pgocaml_ppx + js_of_ocaml-ppx_deriving_json + ocsigen-i18n + ocsigen-ppx-rpc + eliom.ppx.server + -- + --prefix + %%%MODULE_NAME%%%_ + --suffix + _i18n + --default-module + %%%MODULE_NAME%%%_i18n))) (executables - (names %%%PROJECT_NAME%%%) - (modes (byte plugin) (native plugin)) - (libraries eliom.server ocsigen-start.server ocsipersist.pgsql) - (preprocess - (pps - lwt_ppx - pgocaml_ppx - js_of_ocaml-ppx_deriving_json - ocsigen-i18n - ocsigen-ppx-rpc - eliom.ppx.server - -- --prefix %%%MODULE_NAME%%%_ --suffix _i18n --default-module %%%MODULE_NAME%%%_i18n - ) - ) - ) - -(rule (target %%%PROJECT_NAME%%%_i18n.eliom) (deps assets/%%%PROJECT_NAME%%%_i18n.tsv) - (action - (with-stdout-to %{target} - (with-stdin-from %{deps} - (pipe-stdout - (run ocsigen-i18n-generator --languages en,fr --default-language fr %{deps}) - (run sed "1 s/]/[@@deriving json]]\\n[%%shared [@@@ocaml.warning\"-27\"]]/")))))) + (names %%%PROJECT_NAME%%%_main) + (public_names %%%PROJECT_NAME%%%) + (modes + (byte exe) + (native exe)) + (libraries + eliom.server + ocsigen-start.server + ocsipersist-pgsql + ocsigenserver.ext.staticmod + %%%PROJECT_NAME%%%) + (modules %%%MODULE_NAME%%%_main) + (preprocess + (pps + lwt_ppx + pgocaml_ppx + js_of_ocaml-ppx_deriving_json + ocsigen-i18n + ocsigen-ppx-rpc + eliom.ppx.server + -- + --prefix + %%%MODULE_NAME%%%_ + --suffix + _i18n + --default-module + %%%MODULE_NAME%%%_i18n))) + +(rule + (target %%%PROJECT_NAME%%%_i18n.eliom) + (deps assets/%%%PROJECT_NAME%%%_i18n.tsv) + (action + (with-stdout-to + %{target} + (with-stdin-from + %{deps} + (pipe-stdout + (run + ocsigen-i18n-generator + --languages + en,fr + --default-language + fr + %{deps}) + (run + sed + "1 s/]/[@@deriving json]]\\n[%%shared [@@@ocaml.warning\"-27\"]]/")))))) -(rule (target %%%PROJECT_NAME%%%_Demo_i18n.eliom) (deps assets/%%%PROJECT_NAME%%%_Demo_i18n.tsv) +(rule + (target %%%PROJECT_NAME%%%_Demo_i18n.eliom) + (deps assets/%%%PROJECT_NAME%%%_Demo_i18n.tsv) + (action + (with-stdout-to + %{target} + (with-stdin-from + %{deps} + (run + ocsigen-i18n-generator + --primary + %%%PROJECT_NAME%%%_i18n.tsv + --languages + en,fr + --default-language + fr))))) + +(rule + (target %%%PROJECT_NAME%%%_static_config.eliom) + (deps %%%PROJECT_NAME%%%_static_config.eliom.in) + (action + (with-stdout-to + %{target} + (with-stdin-from + %%%PROJECT_NAME%%%_static_config.eliom.in + (run + sed + -e + "s/%%PGPORT%%/%{env:PGPORT=3000}/" + -e + "s/%%PGDATABASE%%/%{env:PGDATABASE=%%%PROJECT_NAME%%%}/" + -e + "s/%%PGDATABASE%%/%{env:PGDATABASE=%%%PROJECT_NAME%%%}/" + -e + "s/%%PGHOST%%/%{env:PGHOST=%%%PROJECT_NAME%%%}/" + -e + "s/%%PGUSER%%/%{env:PGUSER=}/" + -e + "s/%%PGPASSWORD%%/%{env:PGPASSWORD=%%%PROJECT_NAME%%%}/"))))) + +(subdir + gen + (rule + (deps ../tools/gen_dune.ml) (action - (with-stdout-to %{target} - (with-stdin-from %{deps} - (run ocsigen-i18n-generator --primary %%%PROJECT_NAME%%%_i18n.tsv --languages en,fr --default-language fr))))) + (with-stdout-to + dune.client + (run ocaml ../tools/gen_dune.ml))))) + +(subdir + client + (executables + (names %%%PROJECT_NAME%%%) + (modes js byte) + (preprocess + (pps + js_of_ocaml-ppx + lwt_ppx + ocsigen-i18n + -- + --prefix + %%%MODULE_NAME%%%_ + --suffix + _i18n + --default-module + %%%MODULE_NAME%%%_i18n)) + (js_of_ocaml + (build_runtime_flags :standard --enable use-js-string) + (flags + :standard + --enable + with-js-error + --enable + use-js-string + --no-source-map)) + ; source maps are slow... + (libraries eliom.client ocsigen-start.client)) + (dynamic_include ../gen/dune.client)) -(rule (alias %%%PROJECT_NAME%%%) - (deps %%%PROJECT_NAME%%%.cma client/%%%PROJECT_NAME%%%.bc client/%%%PROJECT_NAME%%%.bc.js tools/check_modules.ml) - (action (run ocaml tools/check_modules.ml %%%PROJECT_NAME%%%))) +; Main rule: -(env (_ (flags (:standard -w -9-37-39)))) +(rule + (alias %%%PROJECT_NAME%%%) + (deps + %%%PROJECT_NAME%%%.cma + client/%%%PROJECT_NAME%%%.bc + client/%%%PROJECT_NAME%%%.bc.js + tools/check_modules.ml) + (action + (run ocaml -I +unix -I +str tools/check_modules.ml %%%PROJECT_NAME%%%))) diff --git a/template.distillery/dune-project b/template.distillery/dune-project index 671e67b3..ba1d67e4 100644 --- a/template.distillery/dune-project +++ b/template.distillery/dune-project @@ -1,4 +1,4 @@ -(lang dune 3.0) +(lang dune 3.14) (dialect (name "eliom-server") diff --git a/template.distillery/dune.config b/template.distillery/dune.config new file mode 100644 index 00000000..0e59c63c --- /dev/null +++ b/template.distillery/dune.config @@ -0,0 +1,10 @@ +(env + (_ (env-vars + (PGHOST localhost) + (PGDATABASE %%%PROJECT_NAME%%%) + (PGPORT 3000) +; (PGUSER "") + (PGPASSWORD "") + ) + (flags (:standard -w -9-37-39)) +)) \ No newline at end of file diff --git a/template.distillery/static!images!ocsigen.png b/template.distillery/static!images!ocsigen.png index 7fefaa6f3995fb262935a104642be5e66bf121c8..631857a18bccfe52658ce06b23b43eb26d8fec63 100644 GIT binary patch delta 13 Ucmdl!hkeH!_J%Et=I0o>04V4L`v3p{ delta 11 Scmdlnhkg4T_J%Et=H~z&{{-*= diff --git a/template.distillery/tools!gen_dune.ml b/template.distillery/tools!gen_dune.ml index 41b588f4..6050f271 100644 --- a/template.distillery/tools!gen_dune.ml +++ b/template.distillery/tools!gen_dune.ml @@ -23,7 +23,7 @@ let handle_file_client nm = nm nm let () = - Array.concat (List.map Sys.readdir ["."; "./assets"]) + Array.concat (List.map Sys.readdir ["../../.."; "../../../assets"]) |> Array.to_list |> List.sort compare |> List.filter (fun nm -> nm.[0] <> '.') |> List.iter handle_file_client diff --git a/template.distillery/upgrade.sql b/template.distillery/upgrade.sql deleted file mode 100644 index 53eeb3c3..00000000 --- a/template.distillery/upgrade.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE SCHEMA ocsigen_start; - -ALTER TABLE activation SET SCHEMA ocsigen_start; -ALTER TABLE emails SET SCHEMA ocsigen_start; -ALTER TABLE groups SET SCHEMA ocsigen_start; -ALTER TABLE preregister SET SCHEMA ocsigen_start; -ALTER TABLE user_groups SET SCHEMA ocsigen_start; -ALTER TABLE users SET SCHEMA ocsigen_start; - -ALTER TABLE ocsigen_start.activation ADD COLUMN IF NOT EXISTS expiry timestamp; - -DO $$ BEGIN - DELETE FROM ocsigen_start.groups AS g - WHERE g.groupid IN ( - SELECT g1.groupid - FROM ocsigen_start.groups AS g1 - WHERE EXISTS ( - SELECT * - FROM ocsigen_start.groups AS g2 - WHERE g1.name = g2.name - AND g1.groupid > g2.groupid - ) - ); - IF NOT EXISTS ( - SELECT * - FROM information_schema.constraint_column_usage AS c - WHERE c.table_name = 'groups' - AND c.constraint_name = 'groups_name_key' - AND c.constraint_schema = 'ocsigen_start' - ) THEN - ALTER TABLE ocsigen_start.groups - ADD CONSTRAINT groups_name_key UNIQUE (name); - END IF; -END; $$; From 4c298fe2fe91382b54ade0e0bec918625f9d836f Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Sun, 1 Sep 2024 19:47:21 +0200 Subject: [PATCH 3/4] Template: make install now installs in opam directory --- template.distillery/Makefile.options | 5 ++-- template.distillery/Makefile.os | 37 ++++++++++++++++++--------- template.distillery/PROJECT_NAME.opam | 2 +- template.distillery/README.md | 21 ++++++++++----- 4 files changed, 43 insertions(+), 22 deletions(-) diff --git a/template.distillery/Makefile.options b/template.distillery/Makefile.options index 03c5de8a..a5a9fcd6 100644 --- a/template.distillery/Makefile.options +++ b/template.distillery/Makefile.options @@ -27,13 +27,14 @@ USE_NPM := yes ## The following part contains the configuration for the ocsigenserver. # Port for running the server (make run.*) -PORT := 80 +PORT := 8080 # Port for testing (make test.*) TEST_PORT := 8080 # Root of installation (must end with /) -PREFIX := /usr/local/ +#PREFIX := /usr/local/ +PREFIX := ${OPAM_SWITCH_PREFIX}/ # Local folder for make test.* (must end with /) TEST_PREFIX := local/ diff --git a/template.distillery/Makefile.os b/template.distillery/Makefile.os index 9fa8859b..5da603cb 100644 --- a/template.distillery/Makefile.os +++ b/template.distillery/Makefile.os @@ -47,7 +47,7 @@ all byte opt:: ${VOLATILE_SCHEMA} DIST_FILES = $(ELIOMSTATICDIR)/$(PROJECT_NAME).js $(LIBDIR)/$(PROJECT_NAME).cma -.PHONY: test.byte test.opt staticfiles +.PHONY: test.byte test.opt staticfiles byte opt test.byte:: byte | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles @echo "==== The website is available at http://localhost:$(TEST_PORT) ====" @@ -58,10 +58,10 @@ test.opt:: opt | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles test.static.byte: static.byte | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles @echo "==== The website is available at http://localhost:$(TEST_PORT) ====" - dune exec ./%%%PROJECT_NAME%%%_main.bc + dune exec ./$(PROJECT_NAME)_main.bc test.static.opt: static.opt | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles @echo "==== The website is available at http://localhost:$(TEST_PORT) ====" - dune exec ./%%%PROJECT_NAME%%%_main.exe + dune exec ./$(PROJECT_NAME)_main.exe $(addprefix $(TEST_PREFIX), $(DIST_DIRS)): mkdir -p $@ @@ -73,29 +73,35 @@ staticfiles: ## Static executable static.byte: byte - dune build %%%PROJECT_NAME%%%_main.bc + dune build $(PROJECT_NAME)_main.bc static.opt: opt - dune build %%%PROJECT_NAME%%%_main.exe + dune build $(PROJECT_NAME)_main.exe ##---------------------------------------------------------------------- ## Installing & Running -.PHONY: install install.byte install.byte install.opt install.static install.etc install.lib install.lib.byte install.lib.opt run.byte run.opt +.PHONY: install install.exe install.byte install.byte install.opt install.static install.etc install.lib install.lib.byte install.lib.opt run.byte run.opt install: install.byte install.opt +install.exe: install.etc install.static + dune install install.byte: install.lib.byte install.etc install.static | $(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(shell dirname $(CMDPIPE))) install.opt: install.lib.opt install.etc install.static | $(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(shell dirname $(CMDPIPE))) install.lib: install.lib.byte install.lib.opt -install.lib.byte: $(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cma | $(PREFIX)$(LIBDIR) - install $< $(PREFIX)$(LIBDIR) -install.lib.opt: $(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cmxs | $(PREFIX)$(LIBDIR) - install $< $(PREFIX)$(LIBDIR) +install.lib.byte: byte | $(PREFIX)$(LIBDIR) + install $(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cma $(PREFIX)$(LIBDIR) +install.lib.opt: opt | $(PREFIX)$(LIBDIR) + install $(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cmxs $(PREFIX)$(LIBDIR) install.static: $(TEST_PREFIX)$(ELIOMSTATICDIR)/$(PROJECT_NAME).js | $(PREFIX)$(STATICDIR) $(PREFIX)$(ELIOMSTATICDIR) - cp -r $(LOCAL_STATIC_CSS) $(PREFIX)$(FILESDIR) cp -r $(LOCAL_STATIC_IMAGES) $(PREFIX)$(FILESDIR) cp -r $(LOCAL_STATIC_FONTS) $(PREFIX)$(FILESDIR) [ -z $(WWWUSER) ] || chown -R $(WWWUSER) $(PREFIX)$(FILESDIR) - install $(addprefix -o ,$(WWWUSER)) $< $(PREFIX)$(ELIOMSTATICDIR) + HASH=`md5sum _build/default/client/$(PROJECT_NAME).bc.js | cut -d ' ' -f 1` && \ + install $(addprefix -o ,$(WWWUSER)) $(JS_PREFIX)_$$HASH.js $(PREFIX)$(ELIOMSTATICDIR) && \ + ln -sf $(PROJECT_NAME)_$$HASH.js $(PREFIX)$(ELIOMSTATICDIR)/$(PROJECT_NAME).js + HASH=`cat $(LOCAL_CSS) | md5sum | cut -d ' ' -f 1` && \ + install $(addprefix -o ,$(WWWUSER)) $(CSS_PREFIX)_$$HASH.css $(PREFIX)$(ELIOMSTATICDIR)/css && \ + ln -sf $(PROJECT_NAME)_$$HASH.css $(PREFIX)$(ELIOMSTATICDIR)/css/$(PROJECT_NAME).css install.etc: $(TEST_PREFIX)$(ETCDIR)/$(PROJECT_NAME).conf | $(PREFIX)$(ETCDIR) install $< $(PREFIX)$(ETCDIR)/$(PROJECT_NAME).conf @@ -111,12 +117,19 @@ $(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(ELIOMSTATICDIR) $(shell dirname $(C install $(addprefix -o ,$(WWWUSER)) -d $@ run.byte: + @echo "==== Running ocsigenserver with configuration file ====" @echo "==== The website is available at http://localhost:$(PORT) ====" $(OCSIGENSERVER) $(RUN_DEBUG) -c ${PREFIX}${ETCDIR}/${PROJECT_NAME}.conf run.opt: + @echo "==== Running ocsigenserver with configuration file ====" @echo "==== The website is available at http://localhost:$(PORT) ====" $(OCSIGENSERVER.OPT) $(RUN_DEBUG) -c ${PREFIX}${ETCDIR}/${PROJECT_NAME}.conf +run.static: + @echo "==== Running static executable ====" + @echo "==== The website is available at http://localhost:$(PORT) ====" + ${PROJECT_NAME} + ##---------------------------------------------------------------------- ##---------------------------------------------------------------------- diff --git a/template.distillery/PROJECT_NAME.opam b/template.distillery/PROJECT_NAME.opam index 539e5b27..707c0315 100644 --- a/template.distillery/PROJECT_NAME.opam +++ b/template.distillery/PROJECT_NAME.opam @@ -1,7 +1,7 @@ opam-version: "2.0" name: "%%%PROJECT_NAME%%%" version: "0.1" -synopsis: "Pseudo package for defining project dependencies" +synopsis: "%%%PROJECT_NAME%%%" depends: [ "eliom" {>= "11.0.0" & < "12.0.0"} diff --git a/template.distillery/README.md b/template.distillery/README.md index c4eb3702..a3f9add4 100644 --- a/template.distillery/README.md +++ b/template.distillery/README.md @@ -119,20 +119,27 @@ make test.static.byte (or test.static.opt) make all (or byte or opt) ``` -- DEPRECATED Deploy your project on your system +- Deploy your project on your system ```Shell -sudo make install (or install.byte or install.opt) +make install (or install.byte or install.opt) ``` -- DEPRECATED Run the server on the deployed project +- Run the server on the deployed project ```Shell -sudo make run.byte (or run.opt) +make run.byte (or run.opt) ``` -If Eliom isn't installed globally, however, you need to -re-export some environment variables to make this work: +- Run the static executable of the deployed project ```Shell -sudo PATH=$PATH OCAMLPATH=$OCAMLPATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH make run.byte/run.opt +make run.static +``` + +If you want to use a global install, update PREFIX in `Makefile.options` +and run make ```install``` as root. If OCaml/Eliom is not installed +globally, you will need to re-export some environment variables to make +this work: +```Shell +sudo PATH=$PATH OCAMLPATH=$OCAMLPATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH make run.opt ``` - If you need a findlib package in your project, add it to the From 2caf9d41d1ec329e54b37b01fb36343954e252ba Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Mon, 20 May 2024 19:25:41 +0200 Subject: [PATCH 4/4] 7.0.0 --- opam | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opam b/opam index a039b3de..17f8645f 100644 --- a/opam +++ b/opam @@ -1,6 +1,6 @@ opam-version: "2.0" name: "ocsigen-start" -version: "6.3.0" +version: "7.0.0" authors: "dev@ocsigen.org" maintainer: "dev@ocsigen.org" synopsis: "Higher-level library for developing Web and mobile applications with users, registration, notifications, etc" @@ -23,7 +23,7 @@ depends: [ "pgocaml_ppx" {>= "4.0"} "safepass" {>= "3.0"} "ocsigen-i18n" {>= "4.0.0"} - "eliom" {>= "10.4.0" & < "11.0.0"} + "eliom" {>= "11.0.0" & < "12.0.0"} "ocsigen-toolkit" {>= "2.7.0"} "ocsigen-ppx-rpc" "ocsigen-i18n" {>= "3.7.0"}