Saltar para o conteúdo principal
Versão: v20

Administração

4D provides several integrated tools to start, stop, or monitor the integrated web server.

Iniciando o servidor Web 4D

To be able to launch the web server of 4D or 4D Server, you must have a "4D Web Application" license. For more information, please refer to the 4D Web site.

A 4D project can start and monitor a web server for the main (host) application as well as for each hosted component.

O servidor web principal de 4D pode ser iniciado de diferentes maneiras:

  • Utilizar um botão/comando de menu.

    • 4D: Execução>iniciar servidor Web
    • 4D Server: Start HTTP server button of the HTTP Server page
  • Automatically starting it each time the 4D application is opened. To do this, display the Web\/Configuration page of the Settings and select the Launch Web Server at Startup check box:

  • Programmatically, by calling the webServer.start() function or WEB START SERVER command.

The web server of any component can be launched by calling the webServer.start() function on the component's web server object.

You do not need to relaunch the 4D application to start or stop the web server.

Stopping the 4D Web Server

O servidor web principal de 4D pode ser parado de diferentes maneiras:

  • Using the Run>Stop Web Server menu of 4D or the Stop HTTP server button of the HTTP Server page of 4D Server (both items show Start... when the server is not already started).

  • Programmatically, by calling the webServer.stop() function or WEB STOP SERVER command.

The web server of any component can be stopped by calling the webServer.stop() function on the component's web server object.

Teste do Servidor Web 4D

The Test Web Server command can be used to make sure the built-in web server is functioning correctly (4D only). This command is accessible in the Run menu when the web server is launched:

When you select this command, the home page of the website published by the 4D application is displayed in a window of your default web browser:

This command lets you verify that the web server, home page display, etc. work correctly. The page is called using the localhost URL, which is the standard shortcut designating the IP address of the machine on which the web browser is executed. The command takes into account the TCP publication port number specified in the settings.

Limpar a cache

At any moment, you can clear the cache of the pages and images that it contains (if, for example, you have modified a static page and you want to reload it in the cache).

Para o fazer, pode:

  • To do so, you just have to click on the Clear Cache button in the Web/Options (I) page of the Settings dialog box.
  • 4D Server: click on the Clear Cache button in the HTTP page of the 4D Server Administration window.

A cache é então imediatamente limpa.

Você também pode usar o URL /4DCACHECLEAR.

Explorador de execução

The Watch page (Web heading) in the Runtime Explorer displays web server information, particularly:

  • Web Cache Usage: indicates the number of pages present in the web cache as well as its use percentage. This information is only available if the web server is active and if the cache size is greater than 0.

  • Web Server Elapsed Time: indicates the duration of use (in hours:minutes:seconds format) of the Web server. Esta informação só está disponível se o servidor Web estiver ativo.

  • Web Hits Count: indicates the total number of HTTP requests received since the web server boot, as well as an instantaneous number of requests per second (measure taken between two Runtime Explorer updates). Esta informação só está disponível se o servidor Web estiver ativo.

URLs de administração

Website administration URLS allow you to control the website published on your server. 4D Web Server accepts four particular URLs: /4DSTATS, /4DHTMLSTATS, /4DCACHECLEAR and /4DWEBTEST.

/4DSTATS, /4DHTMLSTATS and /4DCACHECLEAR are only available to the Designer and Administrator of the database. If the 4D password system has not been activated, these URLs are available to all the users. /4DWEBTEST está sempre disponível.

/4DSTATS

The /4DSTATS URL returns several items of information in an HTML table (displayable in a browser):

ElementoDescrição
Tamanho actual da cacheTamanho atual da cache do servidor Web (em bytes)
Tamanho máximo da cacheTamanho máximo da cache (em bytes)
Cached Object Max SizeTamanho máximo de cada objeto na cache (em bytes)
Cache UsePorcentagem do cache usado
Cached ObjectsNumber of objects found in the cache, including pictures

This information can allow you to check the functioning of your server and eventually adapt the corresponding parameters.

The WEB GET STATISTICS command allows you to also obtain information about how the cache is being used for static pages.

/4DHTMLSTATS

The /4DHTMLSTATS URL returns, also as an HTML table, the same information as the /4DSTATS URL. The difference is that the Cached Objects field only counts HTML pages (without counting picture files). Moreover, this URL returns the Filtered Objects field.

ElementoDescrição
Tamanho actual da cacheTamanho atual da cache do servidor Web (em bytes)
Tamanho máximo da cacheTamanho máximo da cache (em bytes)
Cached Object Max SizeTamanho máximo de cada objeto na cache (em bytes)
Cache UsePorcentagem do cache usado
Cached ObjectsNumber of objects found in the cache, without pictures
Objectos filtradosNumber of objects in cache not counted by URL, in particular, pictures

/4DCACHECLEAR

The /4DCACHECLEAR URL immediately clears the cache of the static pages and images. It allows you to therefore “force” the update of the pages that have been modified.

/4DWEBTEST

The /4DWEBTEST URL is designed to check the web server status. When this URL is called, 4D returns a text file with the following HTTP fields filled:

Campo HTTPDescriçãoExemplo
Datedata atual no formato RFC 822Mon, 7 Dec 2020 13:12:50 GMT
Server4D/número da versão4D/18.5.0 (Build 18R5.257368)
User-Agentnome e versão @ endereço IP do clienteMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36 @ 127.0.0.1

Logs

4D permite gerar dois logs de pedidos web:

  • a debug log, useful in the web server development phase (HTTPDebugLog.txt),
  • a standardized web request log, rather used for statistic purposes (logweb.txt).

Both log files are automatically created in the Logs folder of the application project.

HTTPDebugLog.txt

The http debug file can be enabled using the web server object or the WEB SET OPTION command.

Este arquivo registra cada petição HTTP e cada resposta em modo raw (não processado). Petições inteiras, incluindo cabeçalhos, são registradas; opcionalmente, partes do corpo podem ser registradas também.

Os campos abaixo são registrados tanto para Request quanto para Response:

Campo nomeDescrição
SocketIDID da socked usada para comunicação
PeerIPEndereço IPv4 do host (cliente)
PeerPortPorta usada por host (cliente)
TimeStampTimestamp em milisegundos (desde início sistema)
ConnectionIDConnection UUID (UUID de VTCPSocket usada para comunicação)
SequenceNumberNúmero de operação único e sequencial da sessão de histórico

logweb.txt

The web log recording file can be enabled using the web server object, the WEB SET OPTION command, or the Web/Log (type) page of the settings. É necessário selecionar o formato do registo.

CLF/DLF

Each line of the file represents a request, such as: host rfc931 user [DD/MMM/YYYY:HH:MM:SS] "request" state length Each field is separated by a space and each line ends by the CR/LF sequence (character 13, character 10).

DLF (Combined Log Format) format is similar to CLF (Common Log Format) format and uses exactly the same structure. It simply adds two additional HTTP fields at the end of each request: Referer and User-agent. Eis a descrição dos formatos CLF/DLF (não personalizáveis):

Campo nomeDescrição
hostEndereço IP do cliente (por exemplo: 192.100.100.10)
rfc931informação não gerada por 4D, é sempre - (um sinal de menos
useruser name as it is authenticated, or else it is - (a minus sign). Se o nome de usuário contiver espaços, eles serão substituídos por _ (um sublinhado).
DD/MMM/YYYY:HH:MM:SSDD: day, MMM: a 3-letter abbreviation for the month name (Jan, Feb,...), YYYY: year, HH: hour, MM: minutes, SS: seconds. A data e a hora são locais para o servidor.
requestpetição enviada pelo cliente (por exemplo, GET /index.htm HTTP/1.0
stateresposta dada pelo servidor
lengthtamanho dos dados retornados (HTTP header exceto) ou 0
RefererDLF apenas- Contém a URL da página apontando para o documento solicitado.
User-agentDLF only- Contains the name and version of the browser or software of the client at the origin of the request

ELF/WLF

The ELF (Extended Log Format) format is very widespread in the world of HTTP browsers. It can be used to build sophisticated logs that meet specific needs. For this reason, the ELF format can be customized: it is possible to choose the fields to be recorded as well as their order of insertion into the file.

The WLF (WebStar Log Format) was developed specifically for the 4D WebSTAR server.

Configuração dos campos

When you choose the ELF or WLF format, the “Web Log Token Selection” area displays the fields available for the chosen format. You will need to select each field to be included in the log. To do so, check the desired fields. Para o efeito, assinalar os campos pretendidos.

Não é possível selecionar o mesmo campo duas vezes.

The following table lists the fields available for each format (in alphabetical order) and describes its contents:

CampoELFWLFValor
BYTES_RECEIVEDXNúmero de bytes recebidos pelo servidor
BYTES_SENTXXNúmero de bytes enviados pelo servidor ao cliente
C_DNSXXEndereço IP do DNS (ELF: campo idêntico ao campo C_IP)
C_IPXXEndereço IP do cliente (por exemplo, 192.100.100.10)
CONNECTION_IDXNúmero de identificação da ligação
CS(COOKIE)XXInformações sobre as cookies contidas na petição HTTP
CS(HOST)XXCampo Host do pedido HTTP
CS(REFERER)XXURL da página que aponta para o documento solicitado
CS(USER_AGENT)XXInformações sobre o software e o sistema operacional do cliente
CS_SIPXXEndereço IP do servidor
CS_URIXXURI onde o pedido é efectuado
CS_URI_QUERYXXRequest query parameters
CS_URI_STEMXXPart of request without query parameters
DATEXXDDD: dia, MMM: abreviação de 3 letras por mês (jan, fev, etc.), YYYY: ano
METHODXXMétodo HTTP utilizado para o pedido enviado ao servidor
PATH_ARGSXParâmetros CGI: cadeia de caracteres localizada após o carácter "$"
STATUSXXResposta fornecida pelo servidor
TIMEXXHH: hora, MM: minutos, SS: segundos
TRANSFER_TIMEXXTempo solicitado pelo servidor para gerar a resposta
USERXXNome do usuário se estiver autenticado; caso contrário, - (sinal de menos). If the user name contains spaces, they are replaced by _ (underlines)
URLXURL solicitado pelo cliente

As datas e horas são indicadas em GMT.

Frequência do backup

Since a logweb.txt file can become considerably large, it is possible to set up an automatic archiving mechanism. The triggering of a backup can be based on a certain period of time (expressed in hours, days, week or months), or based on the file size; when the set deadline (or file size) is reached, 4D automatically closes and archives the current log file and creates a new one.

When the web log file backup is triggered, the log file is archived in a folder named "Logweb Archives," which is created at the same level as the logweb.txt file.

The archived file is renamed based on the following example: “DYYYY_MM_DD_Thh_mm_ss.txt.” For instance, for a file archived on September 4, 2020 at 3:50 p.m. and 7 seconds: and 7 seconds: e 7 segundos: “D2020_09_04_T15_50_07.txt.”

Parâmetros de backup

The automatic backup parameters for the logweb.txt are set on the Web/Log (backup) page of the Settings:

Configure the automatic backup parameters for the request log. First you must choose the frequency (days, weeks, etc.) or the file size limit criterion by clicking on the corresponding radio button. You must then specify the precise moment of the backup if necessary.

  • No Backup: The scheduled backup function is deactivated.

  • Every X hour(s): This option is used to program backups on an hourly basis. Pode digitar um valor entre 1 e 24.

    • starting at: Used to set the time at which the first back up will begin.
  • Every X day(s) at X: This option is used to program backups on a daily basis. Introduza 1 se pretender efetuar uma cópia de segurança diária. When this option is checked, you must indicate the time when the backup must be started.

  • Every X week(s), day at X: This option is used to program backups on a weekly basis. Digite 1 se quiser realizar o backup 1 vez por semana. Digite 1 se quiser realizar o backup 1 vez por semana. Enter 1 if you want to perform a weekly backup. When this option is checked, you must indicate the day(s) of the week and the time when each backup must be started.

  • Every X month(s), Xth day at X: This option is used to program backups on a monthly basis. Digite 1 se quiser realizar uma cópia de segurança mensal. Digite 1 se quiser realizar uma cópia de segurança mensal.

  • Every X MB: This option is used to program backups based on the size of the current request log file. A backup is automatically triggered when the file reaches the set size. Pode definir um limite de tamanho de 1, 10, 100 ou 1000 MB.