init.d script and installation folder for production systems

187 views
Skip to first unread message

Iván Martínez

unread,
Oct 24, 2011, 2:52:46 PM10/24/11
to Zotonic users
Hello all,
I have a couple of questions about installing Zotonic in a production
server:

- Where do you install Zotonic in production servers, in "/home/
zotonic"? (I suppose there isn't a single answer, I just want to know
what other administrators do).

- I need Zotonic to start after system reboot. Does anyone have a
"init.d" script, or uses another method to achieve this?.

Thank you,
Ivan

Michael Schreckenbauer

unread,
Oct 24, 2011, 2:59:47 PM10/24/11
to zotoni...@googlegroups.com
Hi,

Am Montag, 24. Oktober 2011, 11:52:46 schrieb Iván Martínez:
> Hello all,
> I have a couple of questions about installing Zotonic in a production
> server:
>
> - Where do you install Zotonic in production servers, in "/home/
> zotonic"? (I suppose there isn't a single answer, I just want to know
> what other administrators do).

that's what I did.

> - I need Zotonic to start after system reboot. Does anyone have a
> "init.d" script, or uses another method to achieve this?.

I wrote a basic init.d-script for debian 6.0 today. Supports start, stop,
status and restart. It's not very polished at the moment, but does the job.
Could mail it to you, if interested.

> Thank you,
> Ivan

Best,
Michael

Daniel O'Connell

unread,
Oct 24, 2011, 8:10:40 PM10/24/11
to zotoni...@googlegroups.com
Hi Ivan,

In theory Zotonic can be installed anywhere. But it is more common to install in /home/.

@Michael,

I would love a copy of your init.d script. I still can't restart server using ./bin/zotonic restart (hosted at Webfaction).

Best,
Daniel

Arjan Scherpenisse

unread,
Oct 25, 2011, 4:00:05 AM10/25/11
to zotoni...@googlegroups.com
I just use zotonic's native zotonic command with an init header:

arjan@srv1:~$ cat /etc/init.d/zotonic
#!/bin/sh -e

### BEGIN INIT INFO
# Provides: zotonic
# Required-Start: $postgres $local_fs $remote_fs $network $time
# Required-Stop: $postgres $local_fs $remote_fs $network $time
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Zotonic default
### END INIT INFO

/usr/bin/sudo -u zotonic /home/zotonic/zotonic/bin/zotonic $1

On 10/25/2011 02:10 AM, Daniel O'Connell wrote:
> Hi Ivan,
>
> In theory Zotonic can be installed anywhere. But it is more common to install in /home/.
>
> @Michael,
>
> I would love a copy of your init.d script. I still can't restart server using ./bin/zotonic restart (hosted at Webfaction).
>
> Best,
> Daniel
>
>
> On Oct 24, 2011, at 12:59 PM, Michael Schreckenbauer wrote:
>
>> Hi,
>>

Iván Martínez

unread,
Oct 30, 2011, 9:58:50 AM10/30/11
to Zotonic users
Thank you Arjan and Michael. I have installed in "/home/zotonic" and
I'm using Arjan's script, but I get the following error:

[root@masterion zotonic]# /etc/init.d/zotonic start
Starting zotonic zoton...@masterion.com
/usr/bin/env: escript: No such file or directory
make[1]: *** [compile] Error 127
make: *** [gen_smtp] Error 2
/home/zotonic/zotonic/src/scripts/zotonic-start: line 24: erl: command
not found

Starting with zotonic.sh works fine.

By the way, there seems to be a problem with file permissions in
Zotonic 0.7.1, the files below don't have execution permission:
zotonic/src/scripts/zotonic-status
zotonic/doc/zotonic.sh
Also, why is "zotonic.sh" in the doc folder?.

Thank you,
Ivan

Michael Schreckenbauer

unread,
Oct 30, 2011, 3:37:39 PM10/30/11
to zotoni...@googlegroups.com
Hi,

Am Sonntag, 30. Oktober 2011, 06:58:50 schrieb Iván Martínez:
> Thank you Arjan and Michael. I have installed in "/home/zotonic" and
> I'm using Arjan's script, but I get the following error:
>
> [root@masterion zotonic]# /etc/init.d/zotonic start
> Starting zotonic zoton...@masterion.com
> /usr/bin/env: escript: No such file or directory
> make[1]: *** [compile] Error 127
> make: *** [gen_smtp] Error 2
> /home/zotonic/zotonic/src/scripts/zotonic-start: line 24: erl: command
> not found

I think you need to add the path to erlang in your initscript.
I use
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

My erlang is installed in /usr/local/bin



> Starting with zotonic.sh works fine.

zotonic.sh sets
ERL="/usr/local/bin/erl"

It seems you have installed erlang, where I have, so this works.

> By the way, there seems to be a problem with file permissions in
> Zotonic 0.7.1, the files below don't have execution permission:
> zotonic/src/scripts/zotonic-status

It has in my installation.

> zotonic/doc/zotonic.sh
> Also, why is "zotonic.sh" in the doc folder?.

Afaik zotonic.sh is deprecated. But I'm not sure about this.

Arjan Scherpenisse

unread,
Oct 31, 2011, 4:19:03 AM10/31/11
to zotoni...@googlegroups.com

>
>> zotonic/doc/zotonic.sh
>> Also, why is "zotonic.sh" in the doc folder?.
>
> Afaik zotonic.sh is deprecated. But I'm not sure about this.

Yes. The idea is that you use the 'bin/zotonic' command, which is a
replacement for the old zotonic.sh. It should probably be removed..

I still would like to make zotonic into a debian package. But I'm not
really sure how this would work, with the sites et cetera..

Arjan

Andreas Stenius

unread,
Oct 31, 2011, 4:33:46 AM10/31/11
to zotoni...@googlegroups.com
>> By the way, there seems to be a problem with file permissions in
>> Zotonic 0.7.1, the files below don't have execution permission:
>> zotonic/src/scripts/zotonic-status
>
> It has in my installation.

I've seen this same issue, while being on a windows system. All
src/scripts/* files had x perm, except zotonic-status.

Since it was so easy to fix, I didn't investigate it further...

//Andreas

Arjan Scherpenisse

unread,
Oct 31, 2011, 4:39:43 AM10/31/11
to zotoni...@googlegroups.com
True. I just fixed it and pushed to master.

Iván Martínez

unread,
Nov 1, 2011, 4:22:15 PM11/1/11
to Zotonic users
My PATH seems to be correct, I can run erl with zotonic user:

[root@masterion init.d]# su zotonic
[zotonic@masterion init.d]$ $PATH
bash: /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/
home/ivanmr/bin: No such file or directory
[zotonic@masterion init.d]$ erl
Erlang R14B04 (erts-5.8.5) [source] [rq:1] [async-threads:0] [hipe]
[kernel-poll:false]

Eshell V5.8.5 (abort with ^G)
1>

On Oct 30, 8:37 pm, Michael Schreckenbauer <grim...@gmx.de> wrote:
> Hi,
>
> I think you need to add the path to erlang in your initscript.
> I use
> PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
>
> My erlang is installed in /usr/local/bin
>
> Best,
> Michael

Iván Martínez

unread,
Nov 1, 2011, 4:31:11 PM11/1/11
to Zotonic users
On Oct 31, 9:19 am, Arjan Scherpenisse <ar...@scherpenisse.net> wrote:
> >> zotonic/doc/zotonic.sh
> >> Also, why is "zotonic.sh" in the doc folder?.
>
> > Afaik zotonic.sh is deprecated. But I'm not sure about this.
>
> Yes. The idea is that you use the 'bin/zotonic' command, which is a
> replacement for the old zotonic.sh. It should probably be removed..

The confusing thing is that this doc still refers to zotonic.sh:
http://zotonic.com/documentation/777/deployment#comment-275

> I still would like to make zotonic into a debian package. But I'm not
> really sure how this would work, with the sites et cetera..

May I suggest you first make a "make install" command to install
Zotonic as a system service?. That would be very helpful.

> Arjan

Ivan

Michael Schreckenbauer

unread,
Nov 1, 2011, 4:50:18 PM11/1/11
to zotoni...@googlegroups.com
Am Dienstag, 1. November 2011, 13:22:15 schrieb Iván Martínez:
> My PATH seems to be correct, I can run erl with zotonic user:
>
> [root@masterion init.d]# su zotonic
> [zotonic@masterion init.d]$ $PATH
> bash: /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/
> home/ivanmr/bin: No such file or directory
> [zotonic@masterion init.d]$ erl
> Erlang R14B04 (erts-5.8.5) [source] [rq:1] [async-threads:0] [hipe]
> [kernel-poll:false]
>
> Eshell V5.8.5 (abort with ^G)
> 1>

Try setting it in the initscript. The PATH, that's available to these scripts
might be different from your "normal" PATH. Just add the line below to the top
of the script after the LSB-comments. If it does not work, I was wrong. Still
worth a try imo.

Best,
Michael

Iván Martínez

unread,
Nov 5, 2011, 3:08:15 PM11/5/11
to Zotonic users
Yes, you were right, I had to set the path in bin/zotonic. Now I can
do "/etc/init.d/start" and "/etc/init.d/stop" to start and stop the
service. The problem is it doesn't start on system boot yet. I have
added the service with chkconfig as follows:

[root@masterion bin]# chkconfig --add zotonic
[root@masterion bin]# chkconfig zotonic on
[root@masterion bin]# chkconfig
...
postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
...
zotonic 0:off 1:off 2:on 3:on 4:on 5:on 6:off

PostgreSQL starts but Zotonic doesn't, while both seem to be
configured the same way. I haven't seen any error report, not even in /
access/log (there is an empty "access.log.2011..." file there).

Thank you,
Ivan

Atilla Erdődi

unread,
Nov 5, 2011, 3:31:01 PM11/5/11
to zotoni...@googlegroups.com
Hi Iván,

> PostgreSQL starts but Zotonic doesn't, while both seem to be
> configured the same way. I haven't seen any error report, not even in /
> access/log (there is an empty "access.log.2011..." file there).

Is there anything in priv/sasl? (sasl.log and zotonic.log)

Regards,
Atilla

Iván Martínez

unread,
Nov 5, 2011, 4:44:24 PM11/5/11
to Zotonic users
Nothing at all. Should I start looking about system services failing
to start, rather than Zotonic issues?.
Ivań

Atilla Erdődi

unread,
Nov 6, 2011, 2:51:13 AM11/6/11
to zotoni...@googlegroups.com
Yes, it's probably a good idea. As far as I know, there is always
*some* information present in the sasl logs, when the erlang runtime
starts up - so it might not even be started at all.

Atilla

2011/11/5 Iván Martínez <super...@gmail.com>:

Iván Martínez

unread,
Nov 11, 2011, 1:33:33 PM11/11/11
to Zotonic users
I made it work in my CentOS 6 by modifying the end of Arjan's file as
follows:

...
### END INIT INFO
# chkconfig: 2345 90 10
su - zotonic -c "/home/zotonic/zotonic/bin/zotonic $1"

The chkconfig line is important to make sure it boots after PostgreSQL
and shuts downs before it. "sudo" didn't work for me, I had to replace
it with the "su" command above. At least this is what worked in my
CentOS 6 system.

So let's recapitulate, first you must create zotonic user and group
with its home folder as follows:

groupadd -r zotonic
useradd -r -m -g zotonic zotonic

Become zotonic user ("su zotonic") and as such install Zotonic inside
"/home/zotonic", so Zotonic's root folder is "/home/zotonic/zotonic".

Edit "/home/zotonic/zotonic/bin/zotonic". Add the following line right
after the header comments:

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

Make sure Zotonic's scripts have the proper permits, some may not:

chmod 755 /home/zotonic/zotonic/src/scripts/*

Become root and create "/etc/init.d/zotonic" file, which is Arjan's
file (below) with my modifications (above). Make sure it has the right
permits:

chown root.root /etc/init.d/zotonic
chmod 755 /etc/init.d/zotonic

Install the service:

chkconfig --add zotonic

And again, this is what worked in my CentOS 6.
Ivan Martinez

Michael Schreckenbauer

unread,
Nov 11, 2011, 2:53:02 PM11/11/11
to zotoni...@googlegroups.com
Hi Iván,

thanks a lot for this little how to :)

Best,
Michael

Reply all
Reply to author
Forward
0 new messages