Page 1 of 1

Restarting the service after deploying a configuration

Published: July 20, 2018 - 4:26 PM
by jlabadie
Good morning,

To begin, here is some information regarding the infrastructure:

- Installed WAPT version: 1.5
- Server OS: Linux Debian 9 Stretch
- Administration/package creation machine OS: Windows 7
- One external WAPT server and two additional local repositories on each site


My problem:

I am currently deploying my wapt-get.ini configuration using a package

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = []

def install():

    print('Modify max_gpo_script_wait')
    inifile_writestring(WAPT.config_filename,'global','max_gpo_script_wait',180)

    print('Modify Preshutdowntimeout')
    inifile_writestring(WAPT.config_filename,'global','pre_shutdown_timeout',180)

    print('Disable Hyberboot')
    inifile_writestring(WAPT.config_filename,'global','hiberboot_enabled',0)

    print('Disable Notify User')
    inifile_writestring(WAPT.config_filename,'global','notify_user',0)

    print('Verify cert')
    inifile_writestring(WAPT.config_filename,'global','verify_cert',0)

    print('Modify public_certs_dir')
    inifile_writestring(WAPT.config_filename,'global','public_certs_dir','C:\Program Files (x86)\wapt\ssl')

    print('Modify repo_url')
    inifile_writestring(WAPT.config_filename,'global','repo_url','https://repolocal1/wapt')

    print('Create repositories')
    inifile_writestring(WAPT.config_filename,'global','repositories','repo-externe')

    print('Frequence update')
    inifile_writestring(WAPT.config_filename,'global','waptupdate_task_period',300)

    print('Timeout server')
    inifile_writestring(WAPT.config_filename,'global','wapt_server_timeout',300)

    print('Interdire annulation MAJ')
    inifile_writestring(WAPT.config_filename,'global','allow_cancel_upgrade',1)

    print('Enable repositories')
    inifile_writestring(WAPT.config_filename,'repo-externe','repo_url','https://repoexterne/wapt')

    print('Verify cert secondaire')
    inifile_writestring(WAPT.config_filename,'repo-externe','verify_cert',0)
This works when I add the package to a machine and allows me to modify the main repo in order to retrieve future packages from the local repo.

However, after testing, I realized that the service needed to be restarted, otherwise the retrieval of other packages is done on the externalized server's repo, therefore via HTTP.
The following command allows me to verify this:

Code: Select all

wapt-get show "paquet"



I tried adding this little piece of code to my package:

Code: Select all

def service_restart(WAPTService):
    logger.debug(u'Restarting service %s' % WAPTService)
    win32serviceutil.RestartService(WAPTService)
    win32api.Sleep(2000)
    return win32serviceutil.WaitForServiceStatus(WAPTService, win32service.SERVICE_RUNNING, waitSecs=4)


I have the impression that my service has restarted but I still am not retrieving the packages on the local repo.

If I manually restart the service the problem is solved, but I cannot afford to go to each of the 200 machines.


Sorry for the rather long post, but I tried to summarize the situation as best I could.

Thanks in advance and have a good weekend

Re: Restarting service after deploying a configuration

Published: July 20, 2018 - 4:52 PM
by htouvet
You can ask the service to schedule a restart (in the future)
Restarting the service while a package is being installed is not recommended...


Code: Select all

import requests
...

def install():
    ....
    requests.get('http://127.0.0.1:8088/waptservicerestart.json')


Re: Restarting service after deploying a configuration

Published: July 23, 2018 - 09:09
by jlabadie
Good morning,

By including that part of your script, the service is indeed restarted, but you have to wait a while for the following command to return the correct output from the repository:

Code: Select all

 wapt-get show "paquet" 
That said, it's normal, but isn't there a better way to do it when creating a package that modifies wapt-get.ini?

Re: Restarting service after deploying a configuration

Published: July 23, 2018 - 3:48 PM
by htouvet
It could be something like this:
but some parameters will not be set (hiberboot_enabled, max_gpo_script_wait, pre_shutdown_timeout) because they are set when the service starts.

`def install():
....
WAPT.load_config()
WAPT.update(force=True)`

Re: Restarting service after deploying a configuration

Published: July 24, 2018 - 10:21
by jlabadie
Okay, thank you, I will continue my tests