Start seafile server at system bootup - PROBLEM

1,385 views
Skip to first unread message

Kandi07

unread,
May 3, 2014, 2:31:26 PM5/3/14
to sea...@googlegroups.com

Hi guys,

I have installed successfully seafile on my raspberry pi with MySQL.

I have followed the manual on the official seafile wiki to set up seafile starting at boot.

But I got following error message in my seafile.init.log file:

SQLException: Failed to start connection pool -- Can't connect to MySQL server on '127.0.0.1' (111)
 raised in ConnectionPool_start at src/db/ConnectionPool.c:287


Mysql is already running:

pi@pi ~ $ mysql --host=localhost --user=seafile -p  ccnet-db
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.35-0+wheezy1 (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show database
    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
mysql> show tables;
+--------------------+
| Tables_in_ccnet-db |
+--------------------+
| Binding            |
| EmailUser          |
| Group              |
| GroupUser          |
| OrgGroup           |
| OrgUser            |
| Organization       |
+--------------------+
7 rows in set (0.00 sec)


But seafile isn't running, online seahub:
pi@pi ~ $ pgrep -f "manage.py run_gunicorn" knan# check seahub process
2446
2456
2459
2463
pi@pi ~ $ pgrep -f seafile-controller # check seafile processes
pi@pi ~ $
pi@pi ~ $ ps -eaf | grep 2446
seafile   2446     1  0 20:18 ?        00:00:00 python2.7 /srv/seafile/knan/seafile-server-2.1.5/seahub/manage.py run_gunicorn -c /srv/seafile/knan/seafile-server-2.1.5/runtime/seahub.conf -b 0.0.0.0:8000
seafile   2456  2446  2 20:18 ?        00:00:09 python2.7 /srv/seafile/knan/seafile-server-2.1.5/seahub/manage.py run_gunicorn -c /srv/seafile/knan/seafile-server-2.1.5/runtime/seahub.conf -b 0.0.0.0:8000
seafile   2459  2446  1 20:18 ?        00:00:06 python2.7 /srv/seafile/knan/seafile-server-2.1.5/seahub/manage.py run_gunicorn -c /srv/seafile/knan/seafile-server-2.1.5/runtime/seahub.conf -b 0.0.0.0:8000
seafile   2463  2446  2 20:18 ?        00:00:07 python2.7 /srv/seafile/knan/seafile-server-2.1.5/seahub/manage.py run_gunicorn -c /srv/seafile/knan/seafile-server-2.1.5/runtime/seahub.conf -b 0.0.0.0:8000
pi        2704  2666  0 20:24 pts/0    00:00:00 grep --color=auto 2446


Here is my /etc/init.d/seafile-server
#!/bin/sh

### BEGIN INIT INFO
# Provides:          seafile-server
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts Seafile Server
# Description:       starts Seafile Server
### END INIT INFO

# Change the value of "user" to your linux user name
user=seafile

# Change the value of "script_path" to your path of seafile installation
seafile_dir=/srv/seafile/knan
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log

# Change the value of fastcgi to true if fastcgi is to be used
fastcgi=false
# Set the port of fastcgi, default is 8000. Change it if you need different.
fastcgi_port=8000

case "$1" in
        start)
        date >> ${seafile_init_log}

#!/bin/sh

### BEGIN INIT INFO
# Provides:          seafile-server
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts Seafile Server
# Description:       starts Seafile Server
### END INIT INFO

# Change the value of "user" to your linux user name
user=seafile

# Change the value of "script_path" to your path of seafile installation
seafile_dir=/srv/seafile/knan
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log

# Change the value of fastcgi to true if fastcgi is to be used
fastcgi=false
# Set the port of fastcgi, default is 8000. Change it if you need different.
fastcgi_port=8000

case "$1" in
        start)
        date >> ${seafile_init_log}
        date >> ${seahub_init_log}
                sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
                if [  $fastcgi = true ];
                then
                        sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
                else
                        sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
                fi
        ;;
        restart)
        date >> ${seafile_init_log}
        date >> ${seahub_init_log}
                sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
                if [  $fastcgi = true ];
                then
                        sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
                else
                        sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
                fi
        ;;
        stop)
        date >> ${seafile_init_log}
        date >> ${seahub_init_log}
                sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
                sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
        ;;
        *)
                echo "Usage: /etc/init.d/seafile {start|stop|restart}"
                exit 1
        ;;
esac        date >> ${seahub_init_log}
                sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
                if [  $fastcgi = true ];
                then
                        sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
                else
                        sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
                fi
        ;;
        restart)
        date >> ${seafile_init_log}
        date >> ${seahub_init_log}
                sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
                if [  $fastcgi = true ];
                then
                        sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
                else
                        sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
                fi
        ;;
        stop)
        date >> ${seafile_init_log}
        date >> ${seahub_init_log}
                sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
                sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
        ;;
        *)
                echo "Usage: /etc/init.d/seafile {start|stop|restart}"
                exit 1
        ;;
esac



When I run
/etc/init.d/seafile-server start
after boot it works, but not when the init process should start seafile automatically.

Any idea?

Thanks!

Kind regards,
Kandi07

Shuai Lin

unread,
May 3, 2014, 10:17:34 PM5/3/14
to sea...@googlegroups.com
Hi,

On your script /etc/init.d/seafile-server, you need to specify that "seafile server depends on mysql" like this:

### BEGIN INIT INFO
# Provides:          seafile
# Required-Start:    $local_fs $remote_fs $network $mysql
...

Otherwise mysql server may not be ready when the system tries to launch seafile server at boot time, and seafile server fails to start.



When I run
/etc/init.d/seafile-server start
after boot it works, but not when the init process should start seafile automatically.
 
That's because mysql is ready when you manually run the seafile-server start command.

Regards,
Lin


--
You received this message because you are subscribed to the Google Groups "seafile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seafile+u...@googlegroups.com.
To post to this group, send email to sea...@googlegroups.com.
Visit this group at http://groups.google.com/group/seafile.
For more options, visit https://groups.google.com/d/optout.

Kandi07

unread,
May 4, 2014, 7:35:04 AM5/4/14
to sea...@googlegroups.com
Hi Lin,

I have updated my /etc/init.d/seafile-server script like you described above:
#!/bin/sh

### BEGIN INIT INFO
# Provides:          seafile-server
# Required-Start:    $local_fs $remote_fs $network $mysql

# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts Seafile Server
# Description:       starts Seafile Server


But still got the same error message:

SQLException: Failed to start connection pool -- Can't connect to MySQL server on '127.0.0.1' (111)
 raised in ConnectionPool_start at src/db/ConnectionPool.c:287


I'm using following linux distribution on my raspberry pi:
pi@pi ~ $ cat /etc/issue
Raspbian GNU/Linux 7 \n \l


Kind regards,
Andreas

Stefan Pflug

unread,
May 4, 2014, 1:55:18 PM5/4/14
to sea...@googlegroups.com
Did you update your startup links after changing the init.d script ?

If not try:


sudo update-rc.d seafile remove
sudo update-rc.d seafile defaults

Stefan Pflug

unread,
May 4, 2014, 1:57:25 PM5/4/14
to sea...@googlegroups.com
Replace seafile with seafile-server :-)

Kandi07

unread,
May 4, 2014, 2:39:09 PM5/4/14
to sea...@googlegroups.com
Still the same problem.

Regards,
Kandi07

Philippe Marion

unread,
May 22, 2014, 10:13:20 AM5/22/14
to sea...@googlegroups.com
Hi, 

did you find  a clean solution? ( debian wheezy , and exactly the same problem)

I worked around: 
   - add $mysql   on llne  Required-Start: $.....  of /etc/init.d/seafile-server script
   - moving /etc/rc2.d/S17seafile-server link to /etc/rc2.d/S19seafile-server  (!)
   - change for each command: "sudo -u ${user}"  in :   su - {users} -c "path/sea???.sh start  or : su - {users} -s /bin/bash -c "p.....
(option -s /bin/bash  because my seafileuser has no valid shell)
   - Whatever I do my /etc/init.d/seafile-server script is ok (I can start/stop the service)  but the server doesn' start at boot! 



 Have you also  [failed to run "ccnet-server -t" boot debian]  error message on console at boot ?
 (If you don't have time to read it at screen during boot, you may  apt-get install bootlogd to have the /var/log/boot ... )

My dirty hack is 


Philippe Marion

unread,
May 22, 2014, 10:24:17 AM5/22/14
to sea...@googlegroups.com
Sorry I missed up with my keyboard and post the message before finish efition!...


Le jeudi 22 mai 2014 16:13:20 UTC+2, Philippe Marion a écrit :
Hi, 

did you find  a clean solution? ( debian wheezy , and exactly the same problem)

I worked around: 
   - add $mysql   on llne  Required-Start: $.....  of /etc/init.d/seafile-server script
   - moving /etc/rc2.d/S17seafile-server link to /etc/rc2.d/S19seafile-server  (!)
   - change for each command: "sudo -u ${user}"  in :   su - {users} -c "path/sea???.sh start  or : su - {users} -s /bin/bash -c "p.....
(option -s /bin/bash  because my seafileuser has no valid shell)
   - Whatever I do my /etc/init.d/seafile-server script is ok (I can start/stop the service)  but the server doesn't start at boot! 



 Have you also  [failed to run "ccnet-server -t" boot debian]  error message on console at boot ?
 (If you don't have time to read it at screen during boot, you may  apt-get install bootlogd to have the /var/log/boot ... )

So ... my dirty is , add the line:  
/etc/init.d/seafile-server start    in your /etc/rc.local

... and eventually let the /etc/rcXX.d links  (update-rc.d seafile-server defaults), 
   because all killing links (runlevel 0 1 6) seems to be ok, and produce correct shutdown of the service.
   I deleted the /etc/rc2.d/S17seafile-server link  

Philippe


My dirty hack is 


Michele Innocenti

unread,
May 22, 2014, 10:32:35 AM5/22/14
to sea...@googlegroups.com


Il giorno domenica 4 maggio 2014 13:35:04 UTC+2, Kandi07 ha scritto:
Hi Lin,

I have updated my /etc/init.d/seafile-server script like you described above:
#!/bin/sh

### BEGIN INIT INFO
# Provides:          seafile-server
# Required-Start:    $local_fs $remote_fs $network $mysql
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts Seafile Server
# Description:       starts Seafile Server


But still got the same error message:
SQLException: Failed to start connection pool -- Can't connect to MySQL server on '127.0.0.1' (111)
 raised in ConnectionPool_start at src/db/ConnectionPool.c:287



 When this happens, you can see that mysql is running?
How much ram do you have?

Philippe Marion

unread,
May 26, 2014, 9:33:01 AM5/26/14
to sea...@googlegroups.com
Hi , 
I found a clean solution for debian , maybe it'll works for your Rasp-debian 


Le dimanche 4 mai 2014 04:17:34 UTC+2, Shuai Lin a écrit :
Hi,

On your script /etc/init.d/seafile-server, you need to specify that "seafile server depends on mysql" like this:

### BEGIN INIT INFO
# Provides:          seafile
# Required-Start:    $local_fs $remote_fs $network $mysql
...


1) it seems we shouldn't use the update-rc.d command anymore since squeeze (?), but the "insserv" command

insserv  seafile-server     (insserv -r seafile-server to remove the service)

2)For me it works when I add mysql on the line
 # Required-Start:    $local_fs $remote_fs $network mysql
( without any "$" )
seafile-server script is linked as S19seafile-server , after mysql and the service start correctly at boot 

Philippe/  

 
Reply all
Reply to author
Forward
0 new messages