Restarting the service after deploying a configuration

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
jlabadie
Messages: 3
Registered: July 20, 2018 - 3:56 PM

July 20, 2018 - 4:26 PM

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
Last edited by jlabadie on July 23, 2018 - 08:22, edited 1 time.
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

July 20, 2018 - 4:52 PM

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')

Tranquil IT
jlabadie
Messages: 3
Registered: July 20, 2018 - 3:56 PM

July 23, 2018 - 09:09

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?
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

July 23, 2018 - 3:48 PM

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)`
Tranquil IT
jlabadie
Messages: 3
Registered: July 20, 2018 - 3:56 PM

July 24, 2018 - 10:21

Okay, thank you, I will continue my tests
Locked