diff --git a/CMakeLists.txt b/CMakeLists.txt index f6281b7ad41999e58516a66f3d8f59bdb4b32fe5..140a1b45f1b517a5ae20667196356a4549ad2f1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,6 @@ find_program(LYNX lynx) find_program(CAT cat) find_program(GIT git) find_program(LD ld) -find_program(POD2MAN pod2man) # Define PACKAGE macro in tarantool/config.h set (PACKAGE "Tarantool") @@ -44,6 +43,8 @@ endif() include(GNUInstallDirs) include(cmake/utils.cmake) +include(cmake/pod2man.cmake) +ADD_MANPAGE_TARGET() # the order is significant: we need to know os and compiler to configure libs include(cmake/arch.cmake) diff --git a/cmake/pod2man.cmake b/cmake/pod2man.cmake new file mode 100644 index 0000000000000000000000000000000000000000..efc0153c0209f19b1d5fa6e00373201d64a8342a --- /dev/null +++ b/cmake/pod2man.cmake @@ -0,0 +1,42 @@ +# Generate man pages of the project by using the POD header +# written in the tool source code. To use it - include this +# file in CMakeLists.txt and invoke +# POD2MAN(<podfile> <manfile> <section> <center>) + +FIND_PROGRAM(POD2MAN pod2man) + +MACRO(POD2MAN PODFILE MANFILE SECTION OUTPATH CENTER) + IF(NOT POD2MAN) + MESSAGE(FATAL ERROR "Need pod2man installed to generate man page") + ENDIF(NOT POD2MAN) + + IF(NOT EXISTS ${PODFILE}) + MESSAGE(FATAL ERROR "Could not find pod file ${PODFILE} to generate man page") + ENDIF(NOT EXISTS ${PODFILE}) + + SET(OUTPATH_NEW "${PROJECT_BINARY_DIR}/${OUTPATH}") + + ADD_CUSTOM_COMMAND( + OUTPUT ${OUTPATH_NEW}/${MANFILE}.${SECTION} + COMMAND ${POD2MAN} --section ${SECTION} --center ${CENTER} --release + --stderr --name ${MANFILE} ${PODFILE} > ${OUTPATH_NEW}/${MANFILE}.${SECTION} + ) + + SET(MANPAGE_TARGET "man-${MANFILE}") + ADD_CUSTOM_TARGET(${MANPAGE_TARGET} DEPENDS ${OUTPATH_NEW}/${MANFILE}.${SECTION}) + ADD_DEPENDENCIES(man ${MANPAGE_TARGET}) + + message(STATUS "${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}") + message(STATUS "${MANFILE}.${SECTION} ${OUTPATH_NEW}/${MANFILE}.${SECTION}") + INSTALL( + FILES ${OUTPATH_NEW}/${MANFILE}.${SECTION} + DESTINATION ${CMAKE_INSTALL_MANDIR}/man${SECTION} + ) +ENDMACRO(POD2MAN PODFILE MANFILE SECTION) + +MACRO(ADD_MANPAGE_TARGET) + # It is not possible add a dependency to target 'install' + # Run hard-coded 'make man' when 'make install' is invoked + INSTALL(CODE "EXECUTE_PROCESS(COMMAND make man)") + ADD_CUSTOM_TARGET(man) +ENDMACRO(ADD_MANPAGE_TARGET) diff --git a/debian/rules b/debian/rules index 1ba99320c456dc2632fdd825aa78fb905c23bbc5..23f064f6c591415574aad4e2d50bb92dcb133e5a 100755 --- a/debian/rules +++ b/debian/rules @@ -60,9 +60,3 @@ clean:: install/tarantool:: - -install/tarantool-common:: - sed 's/dist.lua/tarantoolctl/g' extra/dist/dist.lua \ - > ${DEB_BUILDDIR}/tarantoolctl - pod2man -c 'tarantoolctl instances control' \ - ${DEB_BUILDDIR}/tarantoolctl > ${DEB_BUILDDIR}/tarantoolctl.1 diff --git a/debian/tarantool-common.manpages b/debian/tarantool-common.manpages index 58d0e39064e5094d2d4d4ef45b793c76ffea7dc9..6198544dcb4a7a1a2cfb0ffc6c788c0bbf6e0635 100644 --- a/debian/tarantool-common.manpages +++ b/debian/tarantool-common.manpages @@ -1 +1 @@ -build-area/tarantoolctl.1 +build-area/extra/dist/tarantoolctl.1 diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index 08cecf116b37db38cdbbce074fc9690c4015da5d..5fbea6c5e374255d4072383cdb54359e9ffee312 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -1,5 +1,5 @@ -add_custom_target(man ALL - COMMAND ${POD2MAN} -c 'Lua application server and NoSQL database' - ${CMAKE_SOURCE_DIR}/doc/man/tarantool.pod > ${PROJECT_BINARY_DIR}/doc/man/tarantool.1 - ) -install(FILES ${PROJECT_BINARY_DIR}/doc/man/tarantool.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/) +POD2MAN ( + ${CMAKE_SOURCE_DIR}/doc/man/tarantool.pod + "tarantool" 1 doc/man + "Lua application server and NoSQL database" +) diff --git a/doc/user/server-administration.xml b/doc/user/server-administration.xml index e3c279dbb66b80e5421d736606ff1d3b9de9ea85..09d6cfa7b02aefab3ec65787555d57c0aa0ce204 100644 --- a/doc/user/server-administration.xml +++ b/doc/user/server-administration.xml @@ -207,15 +207,15 @@ Explanatory notes about what tarantool displayed in the above example: </section> -<section xml:id="dist.lua"> -<title>Utility <code>dist.lua</code></title> +<section xml:id="tarantoolctl"> +<title>Utility <code>tarantoolctl</code></title> <para> -With dist.lua one can say: "start an instance of the +With tarantoolctl one can say: "start an instance of the Tarantool server which runs a single user-written Lua program, allocating disk resources specifically for that program, via a standardized deployment method." If Tarantool was downloaded from source, then the script -is in ~/extra/dist/dist.lua. If Tarantool was installed +is in ~/extra/dist/tarantoolctl. If Tarantool was installed with debian or Red Hat installation packages, the script is renamed <code>tarantoolctl</code> and is in /usr/bin/tarantoolctl. The script handles such things as: @@ -223,12 +223,12 @@ starting, stopping, rotating logs, logging in to the application's console, and checking status. </para> -<bridgehead renderas="sect4">configuring for dist.lua</bridgehead> +<bridgehead renderas="sect4">configuring for tarantoolctl</bridgehead> <para> -The dist.lua script will read a configuration file +The tarantoolctl script will read a configuration file named /etc/sysconfig/tarantool, or /etc/default/tarantool. Most of the settings are similar to the settings -used by <code>box.cfg{...}</code>; however, dist.lua +used by <code>box.cfg{...}</code>; however, tarantoolctl adjusts some of them by adding an application name. A copy of /etc/sysconfig/tarantool, with defaults for all settings, would look like this:<programlisting> @@ -270,33 +270,33 @@ username = the user that runs the tarantool server. </para> <para> instance_dir = the directory where all applications for this host are stored. -The user who writes an application for dist.lua must put the application's +The user who writes an application for tarantoolctl must put the application's source code in this directory, or a symbolic link. For examples in this section the application name <code>my_app</code> will be used, and its source will have to be in <code><replaceable>instance_dir</replaceable>/my_app.lua</code>. </para> -<bridgehead renderas="sect4">commands for dist.lua</bridgehead> +<bridgehead renderas="sect4">commands for tarantoolctl</bridgehead> <para> -The command format is <code>dist.lua <replaceable>operation</replaceable> application-name</code>, +The command format is <code>tarantoolctl <replaceable>operation</replaceable> application-name</code>, where <replaceable>operation</replaceable> is one of: <code>start</code>, <code>stop</code>, <code>status</code>, <code>logrotate</code>, <code>enter</code>. Thus ...<programlisting> -dist.lua start my_app -- starts application my_app -dist.lua stop my_app -- stops my_app -dist.lua enter my_app -- show my_app's admin console, if it has one -dist.lua logrotate my_app -- rotate my_app's log files (make new, remove old) -dist.lua status my_app -- check my_app's status</programlisting> +tarantoolctl start my_app -- starts application my_app +tarantoolctl stop my_app -- stops my_app +tarantoolctl enter my_app -- show my_app's admin console, if it has one +tarantoolctl logrotate my_app -- rotate my_app's log files (make new, remove old) +tarantoolctl status my_app -- check my_app's status</programlisting> </para> -<bridgehead renderas="sect4">typical code snippets for dist.lua</bridgehead> +<bridgehead renderas="sect4">typical code snippets for tarantoolctl</bridgehead> <para> A user can check whether my_app is running with these lines:<programlisting> - if dist.lua status my_app; then + if tarantoolctl status my_app; then ... fi</programlisting> A user can initiate, for boot time, an init.d set of instructions:<programlisting> for (each file mentioned in the instance_dir directory): - dist.lua start `basename $ file .lua`</programlisting> + tarantoolctl start `basename $ file .lua`</programlisting> A user can set up a further configuration file for log rotation, like this:<programlisting> /path/to/tarantool/*.log { daily @@ -307,15 +307,15 @@ A user can set up a further configuration file for log rotation, like this:<prog delaycompress create 0640 tarantool adm postrotate - /path/to/dist.lua logrotate `basename $ 1 .log` + /path/to/tarantoolctl logrotate `basename $ 1 .log` endscript }</programlisting> </para> -<bridgehead renderas="sect4">A detailed example for dist.lua</bridgehead> +<bridgehead renderas="sect4">A detailed example for tarantoolctl</bridgehead> <para> The example's objective is: make a temporary directory -where dist.lua can start a long-running application +where tarantoolctl can start a long-running application and monitor it. </para> <para> @@ -330,17 +330,17 @@ Create a directory named /tarantool_test:<programlisting> sudo mkdir /tarantool_test</programlisting> </para> <para> -Copy dist.lua to /tarantool_test. +Copy tarantoolctl to /tarantool_test. If you made a source download to ~/tarantool-master, then<programlisting> -sudo cp ~/tarantool-master/extra/dist/dist.lua /tarantool_test/dist.lua</programlisting> +sudo cp ~/tarantool-master/extra/dist/tarantoolctl /tarantool_test/tarantoolctl</programlisting> If the file was named tarantoolctl and placed on /usr/bin/tarantoolctl, then<programlisting> -sudo cp /usr/bin/tarantoolctl /tarantool_test/dist.lua</programlisting> +sudo cp /usr/bin/tarantoolctl /tarantool_test/tarantoolctl</programlisting> </para> <para> -Check and possibly change the first line of /tarantool_test/dist.lua. +Check and possibly change the first line of /tarantool_test/tarantoolctl. Initially it says<programlisting> #!/usr/bin/env tarantool</programlisting> -If that is not correct, edit dist.lua and change the line. +If that is not correct, edit tarantoolctl and change the line. For example, if the Tarantool server is actually on /home/user/tarantool-master/src/tarantool, change the line to<programlisting> #!/usr/bin/env /home/user/tarantool-master/src/tarantool</programlisting> @@ -380,9 +380,9 @@ while 0 == 0 do end</programlisting> </para> <para> -Tell dist.lua to start the application ...<programlisting> +Tell tarantoolctl to start the application ...<programlisting> cd /tarantool_test -sudo ./dist.lua start my_app</programlisting> +sudo ./tarantoolctl start my_app</programlisting> ... expect to see messages indicating that the instance has started. Then ...<programlisting> ls -l /tarantool_test/my_app</programlisting> ... expect to see the .snap file, .xlog file, and sophia directory. Then ...<programlisting> @@ -398,8 +398,8 @@ box.space.tester:select({0},{iterator='GE'})</programlisting> ... expect to see several tuples that my_app has created. </para> <para> -Stop. The only clean way to stop my_app is with dist_lua, thus:<programlisting> -sudo ./dist.lua stop my_app</programlisting> +Stop. The only clean way to stop my_app is with tarantoolctl, thus:<programlisting> +sudo ./tarantoolctl stop my_app</programlisting> </para> <para> Clean up. Restore the original contents of /etc/sysconfig/tarantool, and ...<programlisting> diff --git a/extra/dist/CMakeLists.txt b/extra/dist/CMakeLists.txt index 421689d801a0611a241cf556edaff8778537ff53..34a214256e7d751a16caa62d1ca67f422e066588 100644 --- a/extra/dist/CMakeLists.txt +++ b/extra/dist/CMakeLists.txt @@ -1,4 +1,4 @@ -# Scripts for a dist.lua packaging +# Scripts for a tarantoolctl packaging set(SYSV_INITD_PATH ${CMAKE_INSTALL_LIBDIR}/tarantool/tarantool.init) configure_file("tarantool.service.in" "tarantool.service") @@ -40,10 +40,16 @@ else (ENABLE_RPM) WORLD_READ) endif(ENABLE_RPM) -install (FILES dist.lua DESTINATION ${CMAKE_INSTALL_BINDIR} -RENAME tarantoolctl -PERMISSIONS -OWNER_READ OWNER_WRITE -GROUP_READ GROUP_EXECUTE -WORLD_READ WORLD_EXECUTE) +install (FILES tarantoolctl DESTINATION ${CMAKE_INSTALL_BINDIR} + PERMISSIONS + OWNER_READ OWNER_WRITE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE +) + +POD2MAN ( + ${CMAKE_SOURCE_DIR}/extra/dist/tarantoolctl + "tarantoolctl" 1 extra/dist + "tarantoolctl instances control" +) diff --git a/extra/dist/tarantool.service.in b/extra/dist/tarantool.service.in index cbcde05810b27e854ff4c5d3422b966415544c8b..b930d6ea9d5c1c096c02a37feb04a2455d3d1a28 100644 --- a/extra/dist/tarantool.service.in +++ b/extra/dist/tarantool.service.in @@ -4,7 +4,7 @@ # Recommended way: # 1) Use "/etc/sysconfig/tarantool" or "/etc/default/tarantool" - -# They're supported by our start-stop utility - dist.lua +# They're supported by our start-stop utility - tarantoolctl # Usual way for RPM-based distros # 2) Create a file "/etc/systemd/system/tarantool.service", diff --git a/extra/dist/dist.lua b/extra/dist/tarantoolctl similarity index 90% rename from extra/dist/dist.lua rename to extra/dist/tarantoolctl index 8d1f0ddd7e039c79eb444d2215c03d7e52a61940..d9f5b156006473d5616c953eae7facbfabce8e68 100755 --- a/extra/dist/dist.lua +++ b/extra/dist/tarantoolctl @@ -4,14 +4,14 @@ =head1 NAME -dist.lua - an utility to control tarantool instances +tarantoolctl - an utility to control tarantool instances =head1 SYNOPSIS vim /etc/tarantool/instances.enabled/my_instance.lua - dist.lua start my_instance - dist.lua stop my_instance - dist.lua logrotate my_instance + tarantoolctl start my_instance + tarantoolctl stop my_instance + tarantoolctl logrotate my_instance =head1 DESCRIPTION @@ -25,16 +25,16 @@ The file contains common default instances options: default_cfg = { -- will become pid_file .. instance .. '.pid' pid_file = "/var/run/tarantool", - + -- will become wal_dir/instance/ wal_dir = "/var/lib/tarantool", - + -- snap_dir/instance/ snap_dir = "/var/lib/tarantool", -- sophia_dir/instance/ sophia_dir = "/var/lib/tarantool/sophia", - + -- logger/instance .. '.log' logger = "/var/log/tarantool", @@ -47,27 +47,27 @@ The file contains common default instances options: The file defines C<instance_dir> where user can place his applications (instances). -Each instance can be controlled by C<dist.lua>: +Each instance can be controlled by C<tarantoolctl>: =head2 Starting instance - dist.lua start instance_name + tarantoolctl start instance_name =head2 Stopping instance - dist.lua stop instance_name + tarantoolctl stop instance_name =head2 Logrotate instance's log - dist.lua logrotate instance_name + tarantoolctl logrotate instance_name =head2 Enter instance admin console - dist.lua enter instance_name + tarantoolctl enter instance_name =head2 status - dist.lua status instance_name + tarantoolctl status instance_name Check if instance is up. @@ -81,8 +81,8 @@ exists and socket doesn't, etc. =head2 separate instances control If You use SysV init, You can use symlink from -C<dist.lua> to C</etc/init.d/instance_name[.lua]>. -C<dist.lua> detects if it is started by symlink and uses +C<tarantoolctl> to C</etc/init.d/instance_name[.lua]>. +C<tarantoolctl> detects if it is started by symlink and uses instance_name as C<`basename $0 .lua`>. =head1 COPYRIGHT @@ -117,7 +117,7 @@ local available_commands = { } local function usage() - log.error("Usage: %s [-w] {%s} instance_name", + log.error("Usage: %s {%s} instance_name", arg[0], table.concat(available_commands, '|')) os.exit(1) end @@ -134,16 +134,6 @@ end local cmd = arg[1] --- whether or not this is run from a wrapper which takes --- will daemonize for us -local wrapper = false - -if cmd == '-w' or cmd == '--wrapper' then - wrapper = true - shift_argv(arg, 1, 1) - cmd = arg[1] -end - local valid_cmd = false for _, vcmd in pairs(available_commands) do if cmd == vcmd then @@ -225,11 +215,11 @@ function mk_default_dirs(cfg) if fio.stat(pid_dir) == nil then mkdir(pid_dir) end - -- create wal_dir + -- create wal_dir if fio.stat(cfg.wal_dir) == nil then mkdir(cfg.wal_dir) end - -- create snap_dir + -- create snap_dir if fio.stat(cfg.snap_dir) == nil then mkdir(cfg.snap_dir) end @@ -247,7 +237,7 @@ end local force_cfg = { pid_file = default_cfg.pid_file, username = default_cfg.username, - background = wrapper ~= true, + background = true, custom_proc_title = instance } @@ -258,7 +248,7 @@ wrapper_cfg = function(cfg) cfg[i] = v end - for i, v in pairs(default_cfg) do + for i, v in pairs(default_cfg) do if cfg[i] == nil then cfg[i] = v end @@ -351,9 +341,9 @@ elseif cmd == 'enter' then log.error("Can't connect to %s (socket not found)", console_sock) os.exit(-1) end - + log.info('Connecting to %s', console_sock) - + local cmd = string.format( "require('console').connect('%s')", console_sock) @@ -395,3 +385,5 @@ else log.error("Unknown command '%s'", cmd) os.exit(-1) end + +-- vim: syntax=lua diff --git a/extra/rpm/tarantool.rpm.spec.in b/extra/rpm/tarantool.rpm.spec.in index 7eea1b54109c32ff49f26d20b00e14eb75d69788..4c8655586a04fabd386324dafb9c0c0a1667286b 100644 --- a/extra/rpm/tarantool.rpm.spec.in +++ b/extra/rpm/tarantool.rpm.spec.in @@ -100,7 +100,7 @@ tarantool-pg-module or by tarantool-mysql-module. %if %{with postgresql} %package pg-module -Summary: Tarantool common sql interface +Summary: Tarantool PostgreSQL interface Vendor: tarantool.org Group: Applications/Databases Provides: %{?scl_prefix}tarantool-pg-module @@ -114,9 +114,21 @@ This package provides a PostgreSQL interface to use with tarantool-sql-module. %endif +%package common +Summary: Tarantool common files +Vendor: tarantool.org +Group: Applications/Databases +Provides: %{?scl_prefix}tarantool-common +BuildArch: noarch +%description common +Tarantool is a high performance in-memory NoSQL database. +It supports replication, online backup, stored procedures in Lua. + +This package provides common files + %if %{with mysql} %package mysql-module -Summary: Tarantool common sql interface +Summary: Tarantool MySQL interface Vendor: tarantool.org Group: Applications/Databases Provides: %{?scl_prefix}tarantool-mysql-module @@ -218,6 +230,8 @@ mkdir -m 0755 -p %{_var}/lib/tarantool/ chown tarantool:tarantool %{_var}/lib/tarantool/ mkdir -m 0755 -p %{_sysconfdir}/tarantool/instances.enabled/ mkdir -m 0755 -p %{_sysconfdir}/tarantool/instances.available/ + +%post common %if %{with systemd} %systemd_post tarantool.service %else @@ -225,7 +239,7 @@ chkconfig --add tarantool /sbin/service tarantool start %endif -%preun +%preun common %if %{with systemd} %systemd_preun tarantool.service %else @@ -233,11 +247,6 @@ chkconfig --add tarantool chkconfig --del tarantool %endif -# %%postun -# %%if %%{with systemd} -# %%systemd_postun_with_restart tarantool.service -# %%endif - %files %defattr(-,root,root,-) @@ -249,18 +258,6 @@ chkconfig --del tarantool "%{_mandir}/man1/tarantool.1.gz" -"%{_sysconfdir}/sysconfig/tarantool" - -%if %{with systemd} -"%{_unitdir}/tarantool.service" -"%{_libdir}/tarantool/tarantool.init" -%else -"%{_sysconfdir}/init.d/tarantool" -%endif - -%dir "%{_libdir}/tarantool/" -"%{_bindir}/tarantoolctl" - %files sql-module %defattr(-,root,root,-) %dir "%{_datadir}/tarantool" @@ -293,6 +290,19 @@ chkconfig --del tarantool "%{_includedir}/tarantool/luajit.h" "%{_includedir}/tarantool/lualib.h" +%files common +%defattr(-,root,root,-) +%dir "%{_libdir}/tarantool/" +"%{_bindir}/tarantoolctl" +"%{_mandir}/man1/tarantoolctl.1.gz" +"%{_sysconfdir}/sysconfig/tarantool" +%if %{with systemd} +"%{_unitdir}/tarantool.service" +"%{_libdir}/tarantool/tarantool.init" +%else +"%{_sysconfdir}/init.d/tarantool" +%endif + %changelog * Fri Jun 06 2014 Eugine Blikh <bigbes@tarantool.org> 1.0-2 - Add SCL support