I'm currently working on a parallel multi-node deploy script using Phing and need to know for a specific target, if it has already been invoked.
The target list length varies on node type (let's say staging has three servers and production ten) and we already have parallel execution of targets in place. After all machines have been deployed, I need to update the (single) database server. Is there a way to check for that specific target that it has not been invoked/executed by another thread?
Example:
<target name="run">
<property name="host" value="10.0.0.1, 10.0.0.2, etc..."/>
<parallelforeach list="${host}" param="host" target="execDeploy" delimiter=", "/>
</target>
<target name="execDeploy">
<!-- do some deploy -->
<phincall name="execOnce"/>
</target>
<!-- update DB -->
<target name="execOnce"/>
Is there a way to do this?
edit
I could just add the first IP address to my build.properties, but that's not an elegant solution.
Note: The database is updated through specific code (deployed on each server) through one of the servers, not directly.
Related
Is it possible to configure FreeSWITCH to use SQLite for it's internal database, instead of the default PostgreSQL?
FreeSWITCH uses SQLite as it's default database. Certainly you can change it back to this. You need to make changes in a few places in the XML config files and in the SIP profile parameters. Off the top of my head:
/etc/freeswitch/autoload_configs/switch.conf.xml
Comment out:
<!-- <param name="core-db-dsn" value="XXXXXX" /> -->
Add the following line:
<param name="auto-create-schemas" value="true"/>
Next, in your SIP profiles, comment out or remove the following parameter:
<--<param name="core-db-dsn" value="pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='" />-->
Finally, rescan profile and reload XML in the FreeSWITCH console:
freeswitch> sofia profile <profile_name> [<rescan>|<restart>] reloadxml
Once you modify these parameters, restart FreeSWITCH:
systemctl restart freeswitch
And you should find FreeSWITCH will auto-create databases for the core and SIP profiles automatically.
I think this is most of it. There may be other databases for other modules like mod_callcenter or mod_fifo, but those DSNs are configured in their own config files. This should get you started with the core.
I have a web project that has uses two service endpoints located in the Web.config file under the client --> endpoint --> address portion
I have found the following per Octopus Variables section but cannot seem to find any reference of how to address the changes using and actual variable like you normally would
I am using the webui for Octopus which would be
http://{server-name}/app#/projects/{project-name}/variables
variable-substitution-syntax
I attempted assigning the variables like so, but the values never updated
the original entries look like the following
<endpoint address="http://services-test.example.com/test.svc/soap" binding="basicHttpBinding" bindingConfiguration="soap" contract="test.service" name="soap" />
Name Address Instance
Endpoint[A].Address test-service-a.example.com 1
Endpoint[B].Address test-service-b.example.com 2
Is this something that is ever possible using Octopus Variables? (I know it can be done using regular Web.config Transforms, as we are doing that already).
If it is possible what is would the correct replacement value for the
endpoint address
be and how would I accomplish this for multiple different endpoint addresses?
Sounds like you are most of the way there. If it's already working with your Web.config transforms then all you need to do is replace the value IN the transform with the variable replacement token.
For example: Web.Release.Config
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.serviceModel>
<client>
<endpoint address="http://#{Server1}/test.svc/soap" name="x1"
xdt:Locator="Match(name)" xdt:Transform="SetAttributes(address)" />
<endpoint address="#{Endpoint2}" name="x2"
xdt:Locator="Match(name)" xdt:Transform="SetAttributes(address)" />
</client>
</system.serviceModel>
</configuration>
Of course there are lots of options here.
For filenames you could stick with default conventions 'Web.Release.config' or go with 'Web.[Environment].config' or go with something custom. We use 'Web.Octopus.Config' so that it wont get picked up by any other process.
More on naming transforms here: https://octopus.com/docs/deploying-applications/configuration-files#Configurationfiles-Namingconfigurationtransformfiles
More on custom transforms (Web.Octopus.com) here: https://octopus.com/docs/deploying-applications/configuration-files#Configurationfiles-AdditionalConfigurationTransforms
For variables, you could define a variable for just the server (name=x1) which is simpler or just put the whole address in a variable with gives Octopus a lot more control (name=x2).
The key part is getting the variable replacement tokens into the config. Octopus runs the variable substitution on config files first, and then runs the transforms. What that means is the first pass will replace the tokens in your Web.Release.Config, and then Octopus will run the transforms against Web.config
Hope that helps.
We have a set of WCF Services being hosted in IIS. In our architecture, we have different instances of the service that vary in configuration hosted in subdirectories under the root.
I have a Web.Config in the root that has some configuration information in the AppSettings section. Specifically, it looks like this:
<appSettings>
<add key="Environment" value="Local" />
</appSettings>
In the different subdirectories, I add another Web.config which adds other settings that are specific to the services in that subdirectory.
<appSettings>
<add key="Subdir" value="ABC" />
</appSettings>
However, when I invoke a service (.svc) file in the subdirectory, there is only one value in the ConfigurationManager.AppSettings collection ("Environment"). The "Subdir" key is nowhere to be found. (BTW, the code is written using ConfigurationManager, but I've also tried using WebConfigurationManager, and the result is the same.)
The documentation on MSDN clearly says that the Web.config files in nested directories are supposed to be cumulative. So why isn't my "Subdir" key showing up in that collection?
Thanks in advance for any help you can give me.
For the benefit of anyone else that encounters this, I found the answer.
Even though this app is a service running under IIS, and is being accessed through IIS, the point where this config element is needed is deep down in a derived class of System.ServiceModel.ServiceHostFactory. At that point, HttpContext.Current is null, so the ConfigurationManager has no access to Web directory structure information, and has to depend simply on the application configuration, which is at the top level.
So our solution is to make each Subdirectory an IIS application, and give it all of its own config information in one place.
Has anyone ever tried to implement a web server? Or know something about the underhood of a working web server program? I am wondering what happens exactly from when a URL is received by the web server to a file on the web server is located and sent back as response.
Does the server just keep an internal table to remember the mapping between the URLs it supports and the corresponding local paths? Or is there anything more tricky?
Thanks!
Update
Thanks for your replies. Here's my understanding for now.
I checked with the Microsoft IIS (Internet Information Service), I noticed that IIS can host multiple sites, and foreach site IIS memorize its root path on the local file system. Different sites on the same host share the same host name or IP, and they are differentiated by separate ports. For example:
http://www.myServer.com:1111/folderA/pageA.htm
The web server will use www.myServer.com:1111 part of the URL string to locate which path on its local file system will be used, and then in that local path, it searches for subfolder folderA and then the file pageA.htm.
The web server only need to memorize the following mapping between 2 plain strings:
"http://www.myServer.com:1111/" <---> "D:\myWebRoot"
I don't know where this kind of mapping info is stored, maybe some config files for the Web Server Program in question.
But the result of this mapping granularity is that we could only access content within that mapped local folder. We couldn't do arbitray mapping.
Update - 2 -
I found where the IIS keep the mapping, here's some quotes from applicationHost.config:
<sites>
<site name="Default Web Site" id="1" serverAutoStart="false">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
<binding protocol="net.tcp" bindingInformation="808:*" />
<binding protocol="net.pipe" bindingInformation="*" />
<binding protocol="net.msmq" bindingInformation="localhost" />
<binding protocol="msmq.formatname" bindingInformation="localhost" />
</bindings>
</site>
<site name="myIISService" id="2" serverAutoStart="true">
<application path="/" applicationPool="myIISService">
<virtualDirectory path="/" physicalPath="D:\MySites\MyIISService" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:8022:" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" />
<traceFailedRequestsLogging directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" />
</siteDefaults>
<applicationDefaults applicationPool="DefaultAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
Update - 3 -
After I read foo's reply, my undersanding of a "server" is enlarged. I want to make some comment based on my recent learning of WCF.
No matter what kind of server it is, we could always send messages to them by specifying the protocol, URL, port. For example:
[http://www.myserver.com:1111/]page.htm
[net.tcp://www.myserver.com/]someService.svc/someMethod
[net.msmq://www.myserver.com/]someService.svc
[net.pipe://localhost/]
After the messages arrives at the server program using the parts in square bracket of above URLs, the rest part of the url will send to the server program as input for further processing. And the following behaviour could be as simple as static content feeding or as complex as dynamic content generating.
Depends on the webserver and what its focus is.
(For all items, checking access rights, remapping and such steps apply of course.)
General-purpose webservers like Apache start out with files and directories, so they split up the URL into a hierarchical path description, try to find a file at the given location, and serve it if it exists. (This gets more complex with modules and filetypes; some filetypes imply processing the file as a script and returning the script output rather than just piping out the file contents, and so on).
Application servers like Tomcat do a mapping to servlets; if they have found a servlet that will handle the URL, they call it and pass any leftover URL parts/parameters to it for further handling.
Embedded webservers may even use hardcoded lookup tables for available URL patterns, directly mapping to functions to be called.
Special-purpose webservers will do whatever is required; some won't even parse the URL but just the other headers (like some streaming servers do).
It all depends on what you want to achieve. In most cases, you will be best off with nginx or Apache and maybe some modules and/or finetuning.
Be aware that any HTTP header can be used for mapping the request to whatever means of producing output you have. Hostname, port and URL are used most often, but you may as well take language or client IP or other header data and use them in the mapping.
So for your question: Yes, it can be as simple as that; and yes, it can be substantially more tricky (with mapping, rewriting, and complex processing).
For servers that serve "files", a typical approach is to treat the path portion of the URL as a relative path starting at a "web root" directory defined in the server's configuration. However, a URL doesn't have to correspond to a file on disk at all; it could correspond to an object or method in a running web application, or a database record, or anything else.
For static files there's usually no means of a mapping. The only what the webserver need to know is the absolute disk file system path to the public web document root which is usually definied somewhere in some deployment configuration file (httpd.conf for Apache HTTPD, server.xml and/or context.xml for Apache Tomcat, etc). The webserver extracts the relevant part from the URL, converts it to an absolute disk file system path based on the path to the web document root, locates the file on disk and streams it.
I can set an environment variable with Eclipse when I click on the Tomcat Server and then Open Launch configuration -> Environment -> Variable, Value. What is no-gui, no-eclipse textual-xml equivalent of this variable setting?
Context Parameters
See: Context Parameters section of The Context Container page.
You can configure named values that will be made visible to the web application as servlet context initialization parameters by nesting <Parameter> elements inside this element. For example, you can create an initialization parameter like this:
<Context ...>
...
<Parameter name="companyName" value="My Company, Incorporated"
override="false"/>
...
</Context>
This is equivalent to the inclusion of the following element in the web application deployment descriptor (/WEB-INF/web.xml):
<context-param>
<param-name>companyName</param-name>
<param-value>My Company, Incorporated</param-value>
</context-param>
but does not require modification of the deployment descriptor to customize this value.
If you're using gnu-linux operating system you can edit the catalina.sh script to export you environment variable. First line of the script (after comments, of course) should be
export variableName=variableValue
The credit is for Lucas that told me how to do.
If you meant arguments passed to the launching of your servlet context, see the Answer by miku.
Environment Entries
If you meant the Environment Entries feature, use <Environment> rather than <Parameter> seen in that other Answer.
Here is an example where I set a flag signaling if I am running the web app for development, testing, acceptance, education, or production.
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- Domain: DEV, TEST, ACPT, ED, PROD -->
<Environment name = "work.basil.example.deployment-mode"
description = "Signals whether to run this web-app with development, testing, acceptance, education, or production settings."
value = "DEV"
type = "java.lang.String"
override = "false"
/>
</Context>
You have your choice of a few places to place such XML. For this example, we would want to externalize the file, keeping it outside the WAR file containing our web-app. By externalizing, we can deploy our WAR to any of the dev, test, acpt, ed, or prod servers without needing special builds or manual editing. So for this purpose I like to use the feature of Tomcat allowing for an XML file named the same as the context. The file is place in the conf folder, in which you create nested folders named after the Tomcat engine and the host. For example, on my development machine that would be my_tomcat_base_folder/conf/Catalina/localhost/example.xml where example is the name of my context, Catalina is the engine name, and localhost is the host name (not using a domain name while in development).
The syntax of the above XML is Tomcat-specific. For use in Servlet-standard places, such as the /WEB-INF/web.xml file, the equivalent as documented in the Servlet 4 spec section 14.4.21 would be:
<env-entry>
<env-entry-name>work.basil.example.deployment-mode</env-entry-name>
<description>Signals whether to run this web-app with development, testing, acceptance, education, or production settings.</description>
<env-entry-value>DEV</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>