919 - 926 - 9847

Next up on deck... My First FarCry lib!

I'll add to this post, hopefully to completion, tomorrow. At one point, I had a fairly decent mass mailer set up in FarCry 2.x/3.x. I left that employer but still have most of the code required. It was a modification of the dmEmail object to allow for the a list of emails to be inserted into a variable via CFFILE. You'd upload the list to the server, then import said list to an array.

So, I'm working on site for my son's preschool, and it would be helpful to have similar functionality. But, with a twist. I want the library to capture emails into subscription pools, then use these pools to send out the various emails. The idea being that those looking to get updates from the preschool will join one (or more) of the mailing lists, then receive updates based on the list that was joined. I'll be placing this into the new FarCry 4.0 library feature and making the code available here, and on the FarCry lists/wiki.

Update: I've seriously underestimated this task. Much has changed under the hood of FarCry that I'm only just getting back into. At the moment, the extension to formtools has been created. Dang is that a cool new feature ;). I've got the main display item for Mass Mail distribution 90% complete. But, I've run into an issue of making aObjectIDs for the underlying list emails that gets called. This has REALLY changed, and will take a little more time to deconstruct. It's late, I'm off for now.

Update2: Please bear with me. There's not much going to be accomplished today. I'll try finishing up tonight, but we'll take the day as it comes.

Installing FarCry as a virtual site in IIS

This is specific to the FarCry 4.0 release. At the time of this writing, you can grab it from http://www.jeffcoughlin.com/?pg=11. From this site, be sure to get farcry_core, fourq, farcry_mollio, farcry_lib.farcrycms.

First, our directory structure. Unzip the zips into

You will need to create a project folder. Create a copy of farcry_mollio, and place it into either: C:\farcry40\somesite Or C:\websites\somesite

If the folder is placed outside of the FarCry root, additional steps will need to be followed. Those steps will be listed below. Follow the steps below to complete the installation. Please note that the folder paths used are merely provided as an example.

  1. Open the IIS administrator. Add the virtual site somesite off of your main domain website. Eg. Mainsite.com/somesite. To do this, right click the website to modify, and click New->Virtual Directory.
  2. Fill in the Alias as somesite, click Next. Path will be either C:\farcry40\somesite\www, or the optional folder outside of farcry at C:\websitse\somesite\www.
  3. Choose access permissions as appropriate for your environment. Click Next then Finish to continue.
  4. Create a new virtual directory in a similar fashion for farcry. Right click the newly created somesite folder and click New->Virtual Directory. The alias is farcry and the path is C:\farcry40\farcry_core\admin.
  5. Create a new database user/schema/database/etc to hold the FarCry table information. This document is database agnostic, and assumes the user has some means of affecting these changes. Regardless, FarCry should have its own schema/database to reside in.
  6. Log into the ColdFusion (CF for short) administrator and create mapping for a logical path of /farcry and directory path of C:\farcry40.
  7. Optional - if the project folder is outside of the FarCry folder, create a mapping for a logical path of /farcry/somesite and a directory path of C:\websites\somesite.
  8. Create a new CF datasource called somesite_farcry pointing to the database/schema created in step 5.
  9. And, this was submitted to the FarCry list... change somesite\www\install\FlightCheck.cfc to:
    <cfinclude template="/#arguments.siteName#/install/ping/index.cfm" />
  10. At this point you should now be ready to run the FarCry installation scripts. Open a browser to mainsite.com/somesite/install. If running from somewhere other than localhost, be sure to edit C:\farcry40\somesite\www\install\Application.cfm (or C:\websites\somesite\www\install\Application.cfm) to reflect your IP.
  11. Fill in the required fields. The application name must match the folder name you've created. In this case it is somesite. Fill in the DSN name, and the database type. The website mapping should be /somesite and the FarCry mapping should be /somesite/farcry. Choose to install the farcrycms library, and if in production, remove the installation folder.
  12. At this point, everthing should be ready to go. Click Install and watch the output of the screen. If any errors occur, either report them back to the FarCry mailing list, or investigate where the installer indicates there to be a problem.
  13. Add this line to somesite\config\_serverSpecificVars.cfm: <cfset application.url.webroot = "/somesite">

How to set up muliple instances for just one website

Now, I'm going to preface this with a note. If you multiple websites (eg multiple domains), you are in a much better position than I am. There are caveats to watch out for with multiple instances for just a single site, which will be detailed later on.

My day job is working as a government contractor, and the clients in our shared environment are only given virtual directories off the main domain root. And we're talking about about 50 total applications.

After (finally) getting FusionReactor installed in-house, we have started finding a trend about which applications have been causing problems with our environments. Since we were already using CF installed as J2EE applications, we decided to pull the trouble application into its own instance.

Now, we don't have much clout when it comes to making changes within the environments, so moving this one site into its own domain would/will require lots of paper work, approvals, and time. However, customers don't won't to hear an answer like that, so we came up with a way to work within the system, but didn't require moving a mountain.

So, the steps to get you where you're going:

  • First, I usually have a default cfusion-ear file waiting to roll. However, making a copy of your existing cfusion-ear works fine as well. Create a new folder within your {jrunroot}/servers directory for this new instance. We'll call it instance2. Copy the cfusion-ear file into this directory.
  • Log into the JMS, or click the ColdFusion Enterprise Manger if you have CFMX 7 installed in multiserver mode. Create a new instance and give it the same name as the folder you just created. So, instance2 for example.
  • If this is part of a cluster (mine are), create an instance on the other machine(s). CAUTION: Make certain that each instance, if it's to be part of a cluster, MUST have a unique name. I did not know this until it bit me and caused all kinds of replication issues.
  • If this is part of a cluster, create the cluster and add the instances. Otherwise, skip this step.
  • Start IIS admin (I haven't tested this on apache yet) and create a new website. Doesn't really matter where it points to, or the port that it exists on. This has been tested on IIS 5/6.
  • Start up the JRun website configurator. I generally call the jar file directly as the default JVM is 1.3 on our systems, where the ColdFusion JVM is 1.4 which is required. Add a new site, and select the instance/cluster you just created and map it to the website you just created. Make sure to check to the box to install the ColdFusion connector.
  • You now have a new numbered directory in {jrunroot}/lib/wsconfig. You can now map the virtual directory to use this connector instead of the default connector. Open the properties of the virtual directory, select Configuration from the Directory tab. If you're using IIS 6, you can merely change the filter in one spot. If you're using IIS 5, you need to change the filter for each CFM type file.

Restart IIS and you should be good to go. So how do you know it's working? Well... you could install SeeFusion or FusionReactor. You could check the HTML headers to verify the JSESSIONID. The first four characters should match the {jrunroot}/servers/{instance}/server-inf/connector.properties. You could put code into your application that makes a call to serviceFactory that reports the instance information. And on and on.

So, the caveats:

  • Doing this WILL break CFCHART. In fact, anything that makes a call to /CFIDE that is interpreted by the web.xml file will be affected. There is a solution to this, and it will be the subject of my next blog post
  • You might have issues if you use session replication if the instances are in clusters. Let me give you an example. User visits your www.somesite.com/whatever. There is a link from there to the site in its newly created instance. The JESSIONID from the /whatever site still exists. Uh oh. You'll receive errors about failed session replication in the logs, and the user will get round-robined across the new cluster. This is especially a pain if there is any session information holding user values. The information will not be propagated across the cluster, and the users session will appear to be timed out. The only solution I've found to this is to either destroy the JESSIONID cookie, or pull the instance into its own website.