📜 ⬆️ ⬇️

Deploying Applications in InterSystems Caché

Kazuya Akimoto Ten Blue Eyes

Introduction


So, you have developed your application on InterSystems technologies. Now it must be deployed at the client and often more than once. During the development process, you got an installation manual - because it is not enough just to import the classes, you also need to fine-tune the system with a file and fine-tune the environment for your needs.

To solve these problems there is a utility % Installer . This article is about her.

% Installer


This utility allows you to define an installation manifest that describes the target Caché configuration, rather than steps to achieve it. You describe what should be, and Caché will already generate all the necessary code. You distribute, respectively, only the manifest itself, code generation occurs already in place within a specific Caché server.

To write a manifest, you create an XData block with a description of the desired configuration, as well as a method that generates COS code based on the XData block (it is always the same). Once you have written the manifest, you can call it during the installation of Caché, from a terminal or COS-code. The manifest should be executed in the% SYS area. The manifest is available as system parameters (super-port, OS, mgr directory, etc.), as well as arbitrary parameters passed by the user. Therefore, the installer class must meet the following requirements:
')


Using


A ready installation manifest can be launched in several ways :

Example


Consider a simple example. Create an App.Installer class with an installer that creates an area with the name given by the user:

App.Installer
Include % occInclude
Class App.Installer
{
/// The generated code can be viewed in zsetup + 1 ^ App.Installer.1
XData Install [ XMLNamespace = INSTALLER]
{
< Manifest >
< If Condition = '(## class (Config. Namespaces) .Exists ("$ {Namespace}") = 0)' >
< Log Text = "Creating namespace $ {Namespace}" Level = "0" />
< Namespace Name = "$ {Namespace}" Create = "yes" Code = "$ {Namespace}" Ensemble = "0" Data = "$ {Namespace}" >
< Configuration >
< Database Name = "$ {Namespace}" Dir = "$ {MGRDIR} / $ {Namespace}" Create = "yes" />
</ Configuration >
</ Namespace >
< Log Text = "End Creating namespace $ {Namespace}" Level = "0" />
</ If >
</ Manifest >
}
/// Method that is called to perform the installation.
/// During class compilation, COS code is generated
/// After that, the installer starts with the parameters as follows:
/// Set pVars ("Namespace") = "TempNamespace"
/// Do ## class (App.Installer) .setup (.pVars)
ClassMethod setup ( ByRef pVars , pLogLevel As% Integer = 0 , pInstaller As% Installer.Installer ) As% Status [ CodeMode = objectgenerator, Internal ]
{
Quit ## class ( % Installer.Manifest ). % Generate ( % compiledclass , % code , "Install" )
}
}

In this example, the following happens:


To run from the terminal, execute the following commands:
Set pVars ( "Namespace" ) = "NewNamespace"
Do ## class ( App.Installer ). setup (. pVars )

What will bring
2015-10-16 16:26:18 0 App.Installer: Installation starting at 2015-10-16 16:26:18, LogLevel = 0
2015-10-16 16:26:18 0: Creating namespace NewNamespace
2015-10-16 16:26:19 0: End Creating namespace NewNamespace
2015-10-16 16:26:19 0 App.Installer: Installation succeeded at 2015-10-16 16:26:19
2015-10-16 16:26:19 0% Installer: Elapsed time .605257s

List of items


The manifesto is formed from the following elements:
ElementParent elementAttributes (default)Description
ArgInvoke, errorValue - the value of the argumentPass an argument to a method called via Invoke or Error
ClassmappingConfigurationPackage - package for display
From - the name of the database from which we display
Creates a mapping of classes from a database into a box, inside the Configuration element of which we are
CompileNamespaceClass - the name of the class (s) to compile
Flags - compilation flags (ck)
IgnoreErrors - ignore errors (0)
Compiles classes. Calls $ System.OBJ.Compile (Class, Flags)
ConfigurationNamespaceRequired to create an area and database. The closing tag activates the mappings and updates the cpf file.
CopyclassNamespaceSrc - source class
Target - target class
Replace - delete the original class (0)
Copies or moves the source class to the target.
CopydirManifestSrc - source directory
Targe - target directory
IgnoreErrors - ignore errors (0)
Copy directory
CopyfileManifestSrc - source file
Targe - target file
IgnoreErrors - ignore errors (0)
Copy file
CredentialProductionName - the name of the access details
Username - username
Password - password
Overwrite - override in case of existence
Creates or redefines access credentials.
CSPApplicationNamespaceAuthenticationMethods - Authentication Methods Available
AutoCompile - autocompile
CSPZENEnabled - CSP / ZEN flag
ChangePasswordPage - password change page
CookiePath - path for session cookie
CustomErrorPage - custom error page
DefaultSuperclass - the default super class
DefaultTimeout - session timeout
Description - Description
Directory - path to CSP-files
EventClass - event class
Grant - a list of roles that are issued at the entrance
GroupById - group by id
InboundWebServicesEnabled - inbound web services
IsNamespaceDefault - application for default domain
LockCSPName - lock on CSP name
LoginClass - login page
PackageName - package name
PermittedClasses - Permitted Classes
Recurse - subdirectories (0)
Resource - required resource
ServeFiles - service files
ServeFilesTimeout - timeout for service files
TwoFactorEnabled - two-factor authentication
Url - the name of the web application
UseSessionCookie - use session cookie
Creates or modifies a web application. Detailed description of the settings in the documentation and class Security.Applications
DatabaseConfigurationBlockSize - block size
ClusterMountMode - mount the database as part of a cluster
Collation - sorting
Create - create a database - yes, no, overwrite (yes)
Dir - directory
Encrypted - encrypt
EncryptionKeyID - Encryption Key ID
ExpansionSize - extension
InitialSize - the initial size
MaximumSize - the minimum size
MountAtStartup - mount at startup
MountRequired - mount required
Name - the name
PublicPermissions - public rights
Resource - resource
StreamLocation - stream location
Creates or modifies a database. Detailed description of the settings in the documentation and class Config.Databases
DefaultManifestName - variable name
Value - the value of the variable
Dir - the value of the variable, if it is the path to the folder / file
Defines the value of a variable if it is not defined.
ElseManifest, NamespaceExecuted if the if-condition check is negative
ErrorManifestStatus - error code
Source - the source of the error
Throws an exception. $ {} and # {} syntax not available
ForEachManifestIndex - variable name
Values ​​- a list of variable values
Shared Cycle Operator
GlobalMappingConfigurationGlobal - global name
From - the database name from which we display Collation - sorting (Caché Standard)
Displays the global
IfManifest, NamespaceConditionConditional operator
IfDefManifest, NamespaceVar - variable nameThe conditional operator, if the variable is defined
IfNotDefManifest, NamespaceVar - variable nameThe conditional operator, in case the variable is not defined
ImportNamespaceFile - file / folder for import
Flags - compilation flags (ck)
IgnoreErrors - ignore errors (0)
Recurse - recursive import (0)
Import files. Causes:
$ System.OBJ.ImportDir (File ,, Flags ,, Recurse) and $ System.OBJ.Load (File, Flags)
InvokeNamespaceClass - class
Method - method
CheckStatus - check returned status
Return - write the result to the variable
Calls a class method, you can pass arguments and get the result of the execution.
LoadpageNamespaceName - the path to the CSP page
Dir - folder with CSP pages
Flags - compilation flags (ck)
IgnoreErrors - ignore errors (0)
Loads CSP files via $ System.CSP.LoadPage (Name, Flags) and $ System.CSP.LoadPageDir (Dir, Flags)
LogManifestLevel - logging level from 0 (minimum) to 3 (detailed)
Text - text, up to 32000 characters
Adds a message to the log if the logging level is greater than or equal to the level attribute
ManifestRoot element The only one in the manifest, all other elements are located inside it.
NamespaceManifestName - the name of the area
reate - create region - yes, no, overwrite (yes)
Code - DB with code
Data - database with data
Ensemble - enable Ensemble in the field
Other attributes are associated with Ensemble web applications.
Defines the scope of the installer
ProductionNamespaceName - product name
AutoStart - automatic product launch
Customizes Ensemble products
ResourceManifestName - the name of the resource
Description - Description
Permission - public rights
Creates or modifies a resource.
RoleManifestName - the name of the role
Description - Description
Resources - resources in the form of "MyResource: RW, MyResource1: RWU" RolesGranted - give related roles
Creates a role
RoutineMappingConfigurationRoutines - the name of the routine (s)
Type - one of the types "MAC, INT, INC, OBJ, ALL"
From - from which database
Creates a mapping routine
SettingProductionItem - custom item
Target - setting type: Item, Host, Adapter
Setting - the name of the setting
Value - setting value
Configures an Ensemble product item. Calls the Ens.Production method : ApplySettings
SystemsettingManifestName - class.property of package Config
Value - property value
Sets the value of the Config package properties (via the Modify method)
UserManifestUsername - username
PasswordVar - variable containing the password
Roles - list of user roles
Fullname - full name
Namespace - starting area
Routine - starting routine
ExpirationDate - the date after which the user will no longer be activated
ChangePassword - change password at next login
Enabled - whether the user is activated
Creates or modifies user
VarManifestName - variable name
Value - the value of the variable
Defines the value of a variable.

Variables


Variables can act as attribute values; they are defined in one of three ways:


Parameter values ​​are determined at compile time, so they can be part of a variable or COS expression. Interpretation of variables occurs before the interpretation of the COS-code, so variables can be included in the COS-expression, for example: #{$ZCVT("${NAMESPACE}","L")}.

Environment Variables


The following variables are always available:
VariableDescriptionExample value
Sourcedir(Only when installing Cache) Directory where the installer is located (setup_cache.exe or cinstall)/ InterSystems / distr /
ISCUpgrade(Only when installing Cache) Determines if it is installed or updated0 (installation)
1 (update)
CFGDIRSee INSTALLDIR./ InterSystems / Cache /
CFGFILECpf file path/InterSystems/Cache/cache.cpf
CFGNAMEInstance nameCACHE
CPUCOUNTCPU core numberfour
CSPDIRCSP Directory/ InterSystems / Cache / csp /
HOSTNAMEWeb server nameSCHOOL15
HTTPPORTWeb server port80
INSTALLDIRDirectory where Caché is installed/ InterSystems / Cache /
MGRDIRManagement Directory (mgr)/ InterSystems / Cache / mgr /
PLATFORMoperating systemUNIX
PORTPort superserver Caché1972
PROCESSORPlatform namex86-64
VERSIONCaché Version2015.1.1

Debugging


It is not clear what values ​​attributes can take. For clarification, look at the generated setup method int code. Typically, the main call is the method:

tInstaller.ElementName() ,

those. % Installer.Installer class method that already calls system methods directly. Alternatively, you can look at the %Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART /
TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


class code %Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART /
TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


%Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


%Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


%Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


 %Installer.,      .     %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode. 

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


%Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


%Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


%Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


%Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


%Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


%Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


%Installer., . %OnBeforeGenerateCode, %OnGenerateCode, %OnAfterGenerateCode.

, . TSTART
/ TROLLBACK , Caché ( Caché , ).


MDX2JSON . installer.xml MDX2JSON.Installer. .

:

do ##class(MDX2JSON.Installer).setup()
GitHub-, « » MDX2JSON MDX2JSON, MDX2SJON %All, REST- /MDX2JSON , .


.
Sample.Installer Samples.
CacheGitHubCI .
SYSMON Dashboards .
DeepSee Audit .


%Installer InterSystems Caché Ensemble.


Source: https://habr.com/ru/post/268767/


All Articles