[erlang-questions] Start me up.

Romain Lenglet rlenglet@REDACTED
Wed Nov 15 08:49:38 CET 2006


Pupeno wrote:
> Hello,
> I have what I would call an application or program (from the
> Linux point of view) written in Erlang. It is also an Erlang
> application [1]. I can start and stop my app just fine from
> the Erlang prompt but people don't live in Erlang prompts and
> the init scripts of most OSs expects an actual program in
> /usr/bin or similar and not just an Erlang function. That
> means I ended up writing a script[2] to wrap the Erlang
> function into something that is friendly with the OS. That
> means the script ended having a configuration file[3] which
> means the script[2] has to be processed with sed[4] to perform
> some string replacements[5].
> Isn't there a better alternative ? this really, really sucks.

It does not really sucks. That is the normal way of doing.

However, I have attached better versions of your files. Notably, 
you should detect and substitute the paths to detected commands 
(erl, run_erl, erl_call), in your configuration file, and in the 
defaults section in your script. To do that, see the detection 
code added in configure.ac, and the substitutions in 
Makefile.am.

The paths NAMEFILE, LOGDIR and PIPEDIR should include the normal 
${localstatedir} prefix. Therefore, they should be substituted 
as well.

Your configuration script should go into .../etc (the 
${sysconfdir} directory). See the new variables in the 
Makefile.am, and the substitution in your script.

Since your fanterlasticfour file is an executable script, you can 
use the SCRIPTS primary variable name for this file, instead of 
DATA, in the Makefile.am.


Also, every executable command and every configuration file 
should have a manpage. This is mandatory as for the Debian 
GNU/Linux policy, for instance. I can write manpages for you, if 
you ask gently. (^_^)


Regards,

-- 
Romain LENGLET
Pr. Chiba Shigeru Group
Dept. of Mathematical and Computing Sciences
Tokyo Institute of Technology
-------------- next part --------------
AC_INIT(Modules to write servers, 0.0.0, pupeno@REDACTED, 
serlvers)
AC_COPYRIGHT(Copyright (C) 2006 Jose Pablo Pupeno Fernandez)

dnl Require autoconf version >=2.59c. first one with erlang 
macros
AC_PREREQ(2.59c)
dnl Require automake version >=1.9.5.
AM_INIT_AUTOMAKE(1.9.5)

dnl ----------------------------------------
dnl The interesting part!
AC_ERLANG_NEED_ERL

AC_ARG_VAR([RUN_ERL], [Erlang/OTP interpreter runner [autodetected]])dnl
if test -n "$RUN_ERL"; then
    AC_MSG_CHECKING([for run_erl])
    AC_MSG_RESULT([$RUN_ERL])
else
    AC_PATH_TOOL(RUN_ERL, run_erl, [not found], [])
fi
if test "$RUN_ERL" = "not found"; then
    AC_MSG_ERROR([Erlang/OTP interpreter runner (run_erl) not found but required])
fi

AC_ARG_VAR([ERL_CALL], [Erlang/OTP distributed node caller [autodetected]])dnl
if test -n "$ERL_CALL"; then
    AC_MSG_CHECKING([for erl_call])
    AC_MSG_RESULT([$ERL_CALL])
else
    AC_PATH_TOOL(ERL_CALL, erl_call, [not found], [])
fi
if test "$ERL_CALL" = "not found"; then
    AC_MSG_ERROR([Erlang/OTP distributed node caller (erl_call) not found but required])
fi

dnl ----------------------------------------

AC_CONFIG_FILES([Makefile])

AC_OUTPUT

-------------- next part --------------
# Name of the Erlang node.
NAME="fanterlasticfour"

# Some paths where Fanterlastic Four is going to write files.
NAMEFILE="@NAMEFILE@"
LOGDIR="@LOGDIR@"
PIPEDIR="@PIPEDIR@"

# Programs that Fanterlastic Four needs.
ERL="@ERL@"
RUN_ERL="@RUN_ERL@"
ERL_CALL="@ERL_CALL@"
	
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile.am
Type: text/x-makefile
Size: 977 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20061115/e3889559/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fanterlasticfour.in
Type: application/x-shellscript
Size: 2340 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20061115/e3889559/attachment-0001.bin>


More information about the erlang-questions mailing list