[GH-ISSUE #657] A safe/quick upgrade procedure since 1.2? #613

Closed
opened 2026-02-27 11:12:39 +03:00 by kerem · 12 comments
Owner

Originally created by @piwats on GitHub (Dec 14, 2014).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/657

Hi there,

as 1.2-rc2 was released today (or yesterday ?) I just wanted to upgrade to it.

I see that the pip install --upgrade method won't work, as I ran into the django-versionfiled error again (tha means I have to redeploy completely).

So my question is, does modoboa currently has an upgrade path which does not require a redeployment of the whole installation?

If not, would it be possible to create one, at least some kind of a method which retakes configuration settings from the settings.py and enables them in the freshly deployed folder of modoboa?

This is because I don't think, that the upgrade by completely redeploying the whole setup is a good way to go, at least not when updates coming out frequently - this requires also many things which have to be done manually...

-Paul

Originally created by @piwats on GitHub (Dec 14, 2014). Original GitHub issue: https://github.com/modoboa/modoboa/issues/657 Hi there, as 1.2-rc2 was released today (or yesterday ?) I just wanted to upgrade to it. I see that the pip install --upgrade method won't work, as I ran into the django-versionfiled error again (tha means I have to redeploy completely). So my question is, does modoboa currently has an upgrade path which does not require a redeployment of the whole installation? If not, would it be possible to create one, at least some kind of a method which retakes configuration settings from the settings.py and enables them in the freshly deployed folder of modoboa? This is because I don't think, that the upgrade by completely redeploying the whole setup is a good way to go, at least not when updates coming out frequently - this requires also many things which have to be done manually... -Paul
kerem closed this issue 2026-02-27 11:12:39 +03:00
Author
Owner

@piwats commented on GitHub (Dec 14, 2014):

I now did the upgrade via the redeployment:

would it be possible to add to the

modoboa-admin.py deploy <modoboa_instance_dir> --dbaction upgrade --collectstatic [--with-amavis] [--dburl database-url] [--amavis_dburl database-url] [--domain hostname] [--lang lang] [--timezone timezone]

command also an optional option like --subdir (--nginx_subdir/uwsgi_subdir/ext_web_server_subdir) string which would lead to a correct setting of

LOGIN_URL = '/string/accounts/login/'
STATIC_URL = '/string/sitestatic/'
MEDIA_URL = '/string/media/'

this would make any further changes to the settings.py when redeploying/upgrading obsolete.

That would be nice :)

-Paul

<!-- gh-comment-id:66921955 --> @piwats commented on GitHub (Dec 14, 2014): I now did the upgrade via the redeployment: would it be possible to add to the ``` modoboa-admin.py deploy <modoboa_instance_dir> --dbaction upgrade --collectstatic [--with-amavis] [--dburl database-url] [--amavis_dburl database-url] [--domain hostname] [--lang lang] [--timezone timezone] ``` command also an optional option like --subdir (--nginx_subdir/uwsgi_subdir/ext_web_server_subdir) string which would lead to a correct setting of LOGIN_URL = '/string/accounts/login/' STATIC_URL = '/string/sitestatic/' MEDIA_URL = '/string/media/' this would make any further changes to the settings.py when redeploying/upgrading obsolete. That would be nice :) -Paul
Author
Owner

@controlcde commented on GitHub (Dec 15, 2014):

For me it works if I done in virtualenv: pip install --allow-external django-versionfield modoboa==1.2.0-rc2 but the redeployment went wrong

/srv/#> modoboa-admin.py deploy mailadmin --dbaction upgrade --collectstatic --with-amavis  --dburl mysql://modoboa:PWD@localhost/modoboa  --amavis_dburl mysql://amavis:PWD@localhost/amavis

Traceback (most recent call last):
  File "/srv/venv/modoboa/bin/modoboa-admin.py", line 7, in <module>
    handle_command_line()
  File "/srv/venv/modoboa/local/lib/python2.7/site-packages/modoboa/core/commands/__init__.py", line 90, in handle_command_line
    commands[args.command](commands, verbose=args.verbose).run(remaining)
  File "/srv/venv/modoboa/local/lib/python2.7/site-packages/modoboa/core/commands/__init__.py", line 32, in run
    self.handle(args)
  File "/srv/venv/modoboa/local/lib/python2.7/site-packages/modoboa/core/commands/deploy.py", line 146, in handle
    'startproject', parsed_args.name, verbosity=False
  File "/srv/venv/modoboa/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File "/srv/venv/modoboa/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/srv/venv/modoboa/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/management/commands/startproject.py", line 30, in handle
    super(Command, self).handle('project', project_name, target, **options)
  File "/srv/venv/modoboa/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/management/templates.py", line 82, in handle
    raise CommandError(message)
django.core.management.base.CommandError: '/srv/mailadmin' already exists

Very strange: If i look in the Modoboa web interface I could see under Information "Modoboa 1.2.0-rc2 is currently in use." - which version now I have?

And: Is it necessary to delete the installation and recreate the /srv/mailadmin folder with modoboa-admin.py?

<!-- gh-comment-id:66983421 --> @controlcde commented on GitHub (Dec 15, 2014): For me it works if I done in virtualenv: `pip install --allow-external django-versionfield modoboa==1.2.0-rc2` but the redeployment went wrong ``` /srv/#> modoboa-admin.py deploy mailadmin --dbaction upgrade --collectstatic --with-amavis --dburl mysql://modoboa:PWD@localhost/modoboa --amavis_dburl mysql://amavis:PWD@localhost/amavis Traceback (most recent call last): File "/srv/venv/modoboa/bin/modoboa-admin.py", line 7, in <module> handle_command_line() File "/srv/venv/modoboa/local/lib/python2.7/site-packages/modoboa/core/commands/__init__.py", line 90, in handle_command_line commands[args.command](commands, verbose=args.verbose).run(remaining) File "/srv/venv/modoboa/local/lib/python2.7/site-packages/modoboa/core/commands/__init__.py", line 32, in run self.handle(args) File "/srv/venv/modoboa/local/lib/python2.7/site-packages/modoboa/core/commands/deploy.py", line 146, in handle 'startproject', parsed_args.name, verbosity=False File "/srv/venv/modoboa/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/management/__init__.py", line 159, in call_command return klass.execute(*args, **defaults) File "/srv/venv/modoboa/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/management/base.py", line 285, in execute output = self.handle(*args, **options) File "/srv/venv/modoboa/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/management/commands/startproject.py", line 30, in handle super(Command, self).handle('project', project_name, target, **options) File "/srv/venv/modoboa/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/management/templates.py", line 82, in handle raise CommandError(message) django.core.management.base.CommandError: '/srv/mailadmin' already exists ``` Very strange: If i look in the Modoboa web interface I could see under Information "Modoboa 1.2.0-rc2 is currently in use." - which version now I have? And: Is it necessary to delete the installation and recreate the /srv/mailadmin folder with modoboa-admin.py?
Author
Owner

@piwats commented on GitHub (Dec 15, 2014):

yes the old deployment has to be deleted in order to upgrade - else you get into the error that the folder already exists

<!-- gh-comment-id:66983868 --> @piwats commented on GitHub (Dec 15, 2014): yes the old deployment has to be deleted in order to upgrade - else you get into the error that the folder already exists
Author
Owner

@controlcde commented on GitHub (Dec 15, 2014):

so I have to change the settings.py and wsgi.py after each upgrade to setup up the things that I needed? That´s not very comfortable ;(.

<!-- gh-comment-id:66984089 --> @controlcde commented on GitHub (Dec 15, 2014): so I have to change the settings.py and wsgi.py after each upgrade to setup up the things that I needed? That´s not very comfortable ;(.
Author
Owner

@piwats commented on GitHub (Dec 15, 2014):

wsgi.py?

<!-- gh-comment-id:66984140 --> @piwats commented on GitHub (Dec 15, 2014): wsgi.py?
Author
Owner

@controlcde commented on GitHub (Dec 15, 2014):

For working in my setup with virtualenv I have to add the following lines:

import sys
sys.path.insert(0, '/srv/mailadmin')

activate_this = '/srv/venv/modoboa/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

else it won´t running.

I´ve to say: I don´t use an unusual installation - it´s a Debian Wheezy with apache2.

<!-- gh-comment-id:66984263 --> @controlcde commented on GitHub (Dec 15, 2014): For working in my setup with virtualenv I have to add the following lines: ``` import sys sys.path.insert(0, '/srv/mailadmin') activate_this = '/srv/venv/modoboa/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) ``` else it won´t running. I´ve to say: I don´t use an unusual installation - it´s a Debian Wheezy with apache2.
Author
Owner

@tonioo commented on GitHub (Dec 15, 2014):

Unfortunately, there is no easy way to upgrade a modoboa instance... Doing it manually by reading the documentation requires some work and I don't always have the time for it. From my point of view, forcing people to redeploy avoids stupid mistakes... And the procedure is even more easier for the ones running an automation tool like ansible/chef/puppet/whatever.

About customization, I could add a new option to indicate an extra python file to include at the end of the generated settings.py file... I'll think about it.

About the apache configuration, you're not supposed to modify the wsgi.py file. You should use the daemon mode instead. (see https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/#using-mod-wsgi-daemon-mode)

<!-- gh-comment-id:67001073 --> @tonioo commented on GitHub (Dec 15, 2014): Unfortunately, there is no easy way to upgrade a modoboa instance... Doing it manually by reading the documentation requires some work and I don't always have the time for it. From my point of view, forcing people to redeploy avoids stupid mistakes... And the procedure is even more easier for the ones running an automation tool like ansible/chef/puppet/whatever. About customization, I could add a new option to indicate an extra python file to include at the end of the generated settings.py file... I'll think about it. About the apache configuration, you're not supposed to modify the wsgi.py file. You should use the daemon mode instead. (see https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/#using-mod-wsgi-daemon-mode)
Author
Owner

@controlcde commented on GitHub (Dec 15, 2014):

@tonioo I´ve done the apache2 configuration like described in documentation (or: I think so)

my VirtualEnv path is /srv/venv/modoboa, the modoboa installation path is /srv/mailadmin.
The apache2 configuration is

<VirtualHost *:80>
  ServerName sub.domain.tld
  DocumentRoot /srv/mailadmin/mailadmin

  Alias /media/ /srv/mailadmin/media/
  <Directory /srv/mailadmin/media>
    Order deny,allow
    Allow from all
  </Directory>

  Alias /sitestatic/ /srv/mailadmin/sitestatic/
  <Directory /srv/mailadmin/sitestatic>
    Order deny,allow
    Allow from all
  </Directory>

  WSGIScriptAlias / /srv/mailadmin/mailadmin/wsgi.py
  WSGIDaemonProcess sub.domain.tld python-path=/srv/mailadmin/mailadmin:/srv/venv/modoboa/lib/python2.7/site-packages
  WSGIProcessGroup sub.domain.tld
</VirtualHost>

And if I don´t set up the wsgi.py like I do I get the following error:

 mod_wsgi (pid=14256): Exception occurred processing WSGI script '/srv/mailadmin/mailadmin/wsgi.py'.
 Traceback (most recent call last):
   File "/srv/venv/modoboa/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/handlers/wsgi.py", line 187, in __call__
     self.load_middleware()
   File "/srv/venv/modoboa/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/handlers/base.py", line 44, in load_middleware
     for middleware_path in settings.MIDDLEWARE_CLASSES:
   File "/srv/venv/modoboa/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/conf/__init__.py", line 54, in __getattr__
     self._setup(name)
   File "/srv/venv/modoboa/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/conf/__init__.py", line 49, in _setup
     self._wrapped = Settings(settings_module)
   File "/srv/venv/modoboa/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/conf/__init__.py", line 132, in __init__
     % (self.SETTINGS_MODULE, e)
 ImportError: Could not import settings 'mailadmin.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named mailadmin.settings

<!-- gh-comment-id:67008864 --> @controlcde commented on GitHub (Dec 15, 2014): @tonioo I´ve done the apache2 configuration like described in documentation (or: I think so) my VirtualEnv path is `/srv/venv/modoboa`, the modoboa installation path is `/srv/mailadmin`. The apache2 configuration is ``` <VirtualHost *:80> ServerName sub.domain.tld DocumentRoot /srv/mailadmin/mailadmin Alias /media/ /srv/mailadmin/media/ <Directory /srv/mailadmin/media> Order deny,allow Allow from all </Directory> Alias /sitestatic/ /srv/mailadmin/sitestatic/ <Directory /srv/mailadmin/sitestatic> Order deny,allow Allow from all </Directory> WSGIScriptAlias / /srv/mailadmin/mailadmin/wsgi.py WSGIDaemonProcess sub.domain.tld python-path=/srv/mailadmin/mailadmin:/srv/venv/modoboa/lib/python2.7/site-packages WSGIProcessGroup sub.domain.tld </VirtualHost> ``` And if I don´t set up the `wsgi.py` like I do I get the following error: ``` mod_wsgi (pid=14256): Exception occurred processing WSGI script '/srv/mailadmin/mailadmin/wsgi.py'. Traceback (most recent call last): File "/srv/venv/modoboa/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/handlers/wsgi.py", line 187, in __call__ self.load_middleware() File "/srv/venv/modoboa/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/handlers/base.py", line 44, in load_middleware for middleware_path in settings.MIDDLEWARE_CLASSES: File "/srv/venv/modoboa/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/conf/__init__.py", line 54, in __getattr__ self._setup(name) File "/srv/venv/modoboa/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/conf/__init__.py", line 49, in _setup self._wrapped = Settings(settings_module) File "/srv/venv/modoboa/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/conf/__init__.py", line 132, in __init__ % (self.SETTINGS_MODULE, e) ImportError: Could not import settings 'mailadmin.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named mailadmin.settings ```
Author
Owner

@tonioo commented on GitHub (Dec 15, 2014):

The first element in the python-path list shoud be /srv/mailadmin.

<!-- gh-comment-id:67010349 --> @tonioo commented on GitHub (Dec 15, 2014): The first element in the python-path list shoud be /srv/mailadmin.
Author
Owner

@controlcde commented on GitHub (Dec 15, 2014):

Thanks, now it works. The different paths are irritating for me :) sometimes I have to use /srv/mailadmin - sometimes it is needed to set up /srv/mailadmin/mailadmin (I´ve read many howtos to get modoboa running so maybe a few of them are not 100% correct). It´s a little bit confusing.
After I install modoboa the first time I don´t understood the nested folder with the same name like the site dir - that´s the confusing part of it.

<!-- gh-comment-id:67012399 --> @controlcde commented on GitHub (Dec 15, 2014): Thanks, now it works. The different paths are irritating for me :) sometimes I have to use /srv/mailadmin - sometimes it is needed to set up /srv/mailadmin/mailadmin (I´ve read many howtos to get modoboa running so maybe a few of them are not 100% correct). It´s a little bit confusing. After I install modoboa the first time I don´t understood the nested folder with the same name like the site dir - that´s the confusing part of it.
Author
Owner

@tonioo commented on GitHub (Dec 15, 2014):

This layout is imposed by Django. There is a difference between the top directory which contains your instance and all related files (CSS/JS/whatever) and the sub directory which is a python module. In your case, you don't see any difference because the name does not contain strange characters. The name of the subdirectory must respect the rules applied to python modules.

About the different pathes, only 2 are important :

  • The one that will allow python to locate the module of your instance (so /srv/mailadmin in your case because it contains the mailadmin module, "mailadmin.settings" is actually a python module path)
  • (optional) The path that contains modules of your virtualenv

Do you understand better now ?

<!-- gh-comment-id:67013673 --> @tonioo commented on GitHub (Dec 15, 2014): This layout is imposed by Django. There is a difference between the top directory which contains your instance and all related files (CSS/JS/whatever) and the sub directory which is a python module. In your case, you don't see any difference because the name does not contain strange characters. The name of the subdirectory must respect the rules applied to python modules. About the different pathes, only 2 are important : - The one that will allow python to locate the module of your instance (so /srv/mailadmin in your case because it contains the mailadmin module, "mailadmin.settings" is actually a python module path) - (optional) The path that contains modules of your virtualenv Do you understand better now ?
Author
Owner

@controlcde commented on GitHub (Dec 16, 2014):

Thanks @tonioo for clarification.

<!-- gh-comment-id:67142301 --> @controlcde commented on GitHub (Dec 16, 2014): Thanks @tonioo for clarification.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#613
No description provided.