Fresh seahub 11.0.2 install, seahub failed to start

Hello,
I am on Debian 11, attempting a first time install of seafile and am running into an issue.
Seafile starts finde, but running the ./seahub.sh start ends with "Error: Seahub failed to start.

I changed the “Daemon=True” to “Daemon=False” in the “conf/gunicorn.conf.py” and got the resulting error:

Starting seahub at port 8000 …
Traceback (most recent call last):
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/bin/gunicorn”, line 8, in
sys.exit(run())
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/gunicorn/app/wsgiapp.py”, line 67, in run
WSGIApplication(“%(prog)s [OPTIONS] [APP_MODULE]”).run()
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/gunicorn/app/base.py”, line 231, in run
super().run()
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/gunicorn/app/base.py”, line 72, in run
Arbiter(self).run()
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/gunicorn/arbiter.py”, line 58, in init
self.setup(app)
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/gunicorn/arbiter.py”, line 118, in setup
self.app.wsgi()
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/gunicorn/app/base.py”, line 67, in wsgi
self.callable = self.load()
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/gunicorn/app/wsgiapp.py”, line 58, in load
return self.load_wsgiapp()
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/gunicorn/app/wsgiapp.py”, line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/gunicorn/util.py”, line 359, in import_app
mod = importlib.import_module(module)
File “/usr/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 790, in exec_module
File “”, line 228, in _call_with_frames_removed
File “/opt/seafile/seafile-server-11.0.2/seahub/seahub/wsgi.py”, line 25, in
application = get_wsgi_application()
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/django/core/wsgi.py”, line 12, in get_wsgi_application
django.setup(set_prefix=False)
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/django/init.py”, line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/django/apps/registry.py”, line 116, in populate
app_config.import_models()
File “/opt/seafile/seafile-server-11.0.2/seahub/thirdpart/django/apps/config.py”, line 269, in import_models
self.models_module = import_module(models_module_name)
File “/usr/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 790, in exec_module
File “”, line 228, in _call_with_frames_removed
File “/opt/seafile/seafile-server-11.0.2/seahub/seahub/base/models.py”, line 12, in
from seahub.utils import within_time_range,
File “/opt/seafile/seafile-server-11.0.2/seahub/seahub/utils/init.py”, line 576, in
SeafEventsSession = seafevents_api.init_db_session_class(parsed_events_conf)
AttributeError: ‘NoneType’ object has no attribute ‘init_db_session_class’
Error:Seahub failed to start.
Please try to run “./seahub.sh start” again

How do I fix this?

Any help is appreciated, thank you for the support.

Same here while updaten from 10.* to 11.0.2 (sadly 11.0.3 is still not for download).

While upgrading I got following message:

seafile@arkanoid ~/seafile-server-11.0.2/upgrade $ ./upgrade_10.0_11.0.sh

-------------------------------------------------------------
This script would upgrade your seafile server from 10.0 to 11.0
Press [ENTER] to contiune
-------------------------------------------------------------



Updating seafile/seahub database ...

[INFO] You are using MySQL
[INFO] updating seahub database...
[WARNING] Failed to execute sql: (1054, "Unknown column 'domain' in 'org_saml_config'")
Done

migrating avatars ...

Done

After starting seahub.sh manually in debug mode I got exactly same error. I assume some database with is or was in Pro version related to the seafevents new component (for CE users) and not in CE, that should be created as well.

The 11.0.3 release is there but the download link seems to be out-of-date. Try this link.

1 Like

I used that link to get the 11.0.3 version, after installing that i still get the same error trying to start the seahub.sh

Blockquote
Starting seahub at port 8000 …
Traceback (most recent call last):
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/bin/gunicorn”, line 8, in
sys.exit(run())
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/gunicorn/app/wsgiapp.py”, line 67, in run
WSGIApplication(“%(prog)s [OPTIONS] [APP_MODULE]”).run()
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/gunicorn/app/base.py”, line 231, in run
super().run()
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/gunicorn/app/base.py”, line 72, in run
Arbiter(self).run()
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/gunicorn/arbiter.py”, line 58, in init
self.setup(app)
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/gunicorn/arbiter.py”, line 118, in setup
self.app.wsgi()
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/gunicorn/app/base.py”, line 67, in wsgi
self.callable = self.load()
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/gunicorn/app/wsgiapp.py”, line 58, in load
return self.load_wsgiapp()
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/gunicorn/app/wsgiapp.py”, line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/gunicorn/util.py”, line 359, in import_app
mod = importlib.import_module(module)
File “/usr/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 790, in exec_module
File “”, line 228, in _call_with_frames_removed
File “/opt/seafile/seafile-server-11.0.3/seahub/seahub/wsgi.py”, line 25, in
application = get_wsgi_application()
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/django/core/wsgi.py”, line 12, in get_wsgi_application
django.setup(set_prefix=False)
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/django/init.py”, line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/django/apps/registry.py”, line 116, in populate
app_config.import_models()
File “/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/django/apps/config.py”, line 269, in import_models
self.models_module = import_module(models_module_name)
File “/usr/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 790, in exec_module
File “”, line 228, in _call_with_frames_removed
File “/opt/seafile/seafile-server-11.0.3/seahub/seahub/base/models.py”, line 12, in
from seahub.utils import within_time_range, gen_token,
File “/opt/seafile/seafile-server-11.0.3/seahub/seahub/utils/init.py”, line 576, in
SeafEventsSession = seafevents_api.init_db_session_class(parsed_events_conf)
AttributeError: ‘NoneType’ object has no attribute ‘init_db_session_class’
Error:Seahub failed to start.
Please try to run “./seahub.sh start” again

I got it to work!

I change the following in the error causing section:

/opt/seafile/seafile-server-11.0.3/seahub/seahub/utils/init .py”
Line 577

try:
EVENTS_ENABLED = True
SeafEventsSession = seafevents_api.init_db_session_class(parsed_events_conf)
except ImportError:
logging.exception(‘Failed to import seafevents package.’)
seafevents = None
EVENTS_ENABLED = False

to:

try:
    EVENTS_ENABLED = True
    SeafEventsSession = seafevents_api.init_db_session_class(parsed_events_conf)
except :
    logging.exception('Failed to import seafevents package.')
    seafevents = None
    EVENTS_ENABLED = False

Could you please check “tail -f seafile-monitor.log” if you are getting errors? I had discovered that the upgrade script upgrade_10.0_11.0.sh doesn’t work properly when you have configured to use mariadb/mysqldb with sockets instead with “host” and “port”. I have to adapt he upgrade script to write host = /run/mysqld/mysqld.sock instead of i.e. 0.0.0.0 but this was not enough because after that I got the error : sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1044, "Access denied for user 'seafile'@'localhost' to database 'run/mysqld/mysqld.sock:3306/seahub-db'") after starting Seafile service (note that Seafile service unit is able to start fine, but you just realize of the problem when you check the seafile-monitoring.log). This was produced because in case you don’t put any PORT entry in seafevents.conf, it will take the standard one(3306), but in my case is resulting in a malformed path. I think here is some homework to do…
after this is fixed I didn’t get anymore our mentioned error:

AttributeError: ‘NoneType’ object has no attribute ‘init_db_session_class’
    Error:Seahub failed to start.

And seahub starts fine (without cheat the python code "except ImportError:" as you mentioned. Myybe was your issue as well?

I just checked my seafile-monitor.log and seem to be getting the following error constantly:

[2023-12-31 10:38:18] Start seafevents.main
Traceback (most recent call last):
File “/usr/lib/python3.9/runpy.py”, line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File “/usr/lib/python3.9/runpy.py”, line 87, in _run_code
exec(code, run_globals)
File “/opt/seafile/seafile-server-11.0.3/pro/python/seafevents/main.py”, line 6, in
from seafevents.db import create_db_tables, prepare_db_tables
File “/opt/seafile/seafile-server-11.0.3/pro/python/seafevents/db.py”, line 8, in
from sqlalchemy.orm import mapped_column
ImportError: cannot import name ‘mapped_column’ from ‘sqlalchemy.orm’ (/home/seafile/.local/lib/python3.9/site-packages/sqlalchemy/orm/init.py)

Would this be resulting from your described error? I am using mariadb on the standard port 3306 so those parameters would match.
I do have the port = 3306 defined in my seafevents.conf with host = 127.0.0.1 currently.

I remember well having same error as you have, the one with the “mapped_column”. The issue, so far as I remember was solved installing the proper sqlalchemy python package, as described in the upgrade guide to v11.. I remember installing the same python packages for the user seafile as well. After that, restart the Seafile and Seahub service units.

Edited 16.01.2023: for sqlalchemy installation see in Github the explanation behind that.

1 Like

I have a similar error, also getting the ImportError from /opt/seafile/seafile-server-11.0.3/seahub/seahub/utils/__init__.py

But for some reason I do get a popup when creation a lib printing an Error Error! and when deleting Failed to delete xxx but the action was done in the background. Doing a page refresh, the lib is created or gone so it is just an nasty issue that this misleading popup comes up.

Is this from the exception not handled correctly?

ImportError: cannot import name 'SeafEventsSession' from 'seahub.utils' (/opt/seafile/seafile-server-11.0.3/seahub/seahub/utils/__init__.py)
2024-01-16 09:02:52,071 [ERROR] django.request:241 log_response Internal Server Error: /api2/repos/
Traceback (most recent call last):
  File "/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-11.0.3/seahub/seahub/api2/base.py", line 23, in dispatch
    response = super(APIView, self).dispatch(*a, **kw)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-11.0.3/seahub/seahub/api2/base.py", line 20, in handle_exception
    return super(APIView, self).handle_exception(exc)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-11.0.3/seahub/seahub/api2/views.py", line 1005, in post
    repo_created.send(sender=None,
  File "/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/django/dispatch/dispatcher.py", line 176, in send
    return [
           ^
  File "/opt/seafile/seafile-server-11.0.3/seahub/thirdpart/django/dispatch/dispatcher.py", line 177, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/seafile/seafile-server-11.0.3/seahub/seahub/handlers.py", line 44, in repo_created_cb
    from .utils import SeafEventsSession

found how to solve the issue, since as I have read the OSS does not have the Events recording, commenting out the SeafEventsSession recording fixes the issue. No idea why this is not covered?

diff --git a/opt/seafile/seafile-server-11.0.3/seahub/seahub/handlers.py b/opt/seafile/seafile-server-11.0.2/seahub/seahub/handlers.py
index 5317b0c..20a5d2c 100644
--- a/opt/seafile/seafile-server-11.0.3/seahub/seahub/handlers.py
+++ b/opt/seafile/seafile-server-11.0.2/seahub/seahub/handlers.py
@@ -41,10 +41,10 @@ try:
             'org_id': org_id,
         }

-        #from .utils import SeafEventsSession
-        #session = SeafEventsSession()
-        #seafevents_api.save_user_activity(session, record)
-        #session.close()
+        from .utils import SeafEventsSession
+        session = SeafEventsSession()
+        seafevents_api.save_user_activity(session, record)
+        session.close()

         LIBRARY_TEMPLATES = getattr(settings, 'LIBRARY_TEMPLATES', {})
         library_template = kwargs['library_template']
@@ -90,10 +90,10 @@ try:
             'org_id': org_id if org_id and org_id > 0 else -1,
         }

-        #from .utils import SeafEventsSession
-        #session = SeafEventsSession()
-        #seafevents_api.save_user_activity(session, record)
-        #session.close()
+        from .utils import SeafEventsSession
+        session = SeafEventsSession()
+        seafevents_api.save_user_activity(session, record)
+        session.close()

     def clean_up_repo_trash_cb(sender, **kwargs):
         """When a repo trash is deleted, the operator will be recorded.
@@ -127,10 +127,10 @@ try:
             'org_id': org_id,
         }

-        #from .utils import SeafEventsSession
-        #session = SeafEventsSession()
-        #seafevents_api.save_user_activity(session, record)
-        #session.close()
+        from .utils import SeafEventsSession
+        session = SeafEventsSession()
+        seafevents_api.save_user_activity(session, record)
+        session.close()