Would you like to contribute to the Titanium docs? To get started, sign up for an account on the Appcelerator Wiki and sign our CLA.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: change Arrow Cloud to API Runtime Services

...

That's it! Your application is running in the

Multiexcerpt include
MultiExcerptNamearrow-arrow-cloud
PageWithExcerptDPV:Arrow Products
 cloud.
Multiexcerpt
MultiExcerptNamedeploy

Deploy the Application

To deploy an application to Arrow Cloud

Multiexcerpt include
MultiExcerptNamearrow-arrow-cloud
PageWithExcerptDPV:Arrow Products
, run the appc cloud publish command from the Arrow Cloud
Multiexcerpt include
MultiExcerptNamearrow-arrow-cloud
PageWithExcerptDPV:Arrow Products
project directory.  Your project source code will be uploaded to the Arrow Cloud
Multiexcerpt include
MultiExcerptNamearrow-arrow-cloud
PageWithExcerptDPV:Arrow Products
where npm install will be executed against the project, which downloads and installs any NPM module dependencies.  When installation completes, the application is executed using node.

If the application is already deployed, you need to either increment the version field in the package.json file to publish a new version of the application or pass the --force flag to the publish command to republish the application. Before republishing the application, Arrow Cloud

Multiexcerpt include
MultiExcerptNamearrow-arrow-cloud
PageWithExcerptDPV:Arrow Products
sends the SIGTERM signal to the currently deployed application to let it shutdown gracefully. If the app does not shutdown in time, Arrow Cloud
Multiexcerpt include
MultiExcerptNamearrow-arrow-cloud
PageWithExcerptDPV:Arrow Products
will kill the application.

Github Repository

To deploy an application stored in a Github repository to Arrow Cloud

Multiexcerpt include
MultiExcerptNamearrow-arrow-cloud
PageWithExcerptDPV:Arrow Products
, run the appc cloud publish --git repo=GITHUB_URL.  You may optionally pass in a branch using the branch parameter.  If your repo is private, you will need to pass in either your Github account credentials with the username and password parameters or personal access token generated by Github with the access_token parameter.  You may also pass in the parameters in a configuration file in JSON format.

To generate a Github personal access token:

  1. Log into Github.
  2. Click the Settings icon (gear) in the top navigation bar.
  3. Click Applications in the left navigation bar.
  4. Under Personal Access Tokens, click Generate new token.
  5. Make sure the repo and public_repo scopes are selected.
  6. Click Generate token.

The token will be available in the Applications page of your settings.

Code Block
### Publish a Public Repo
appc cloud publish --git repo=https://github.com/jdoe/PublicTestApp.git,branch=master
 
### Publish a Private Repo with an access token
appc cloud publish --git repo=https://github.com/jdoe/PrivateTestApp.git,branch=master,access_token=your_access_token
 
### Publish a Private Repo with Github credentials
appc cloud publish --git repo=https://github.com/jdoe/PrivateTestApp.git,branch=master,username=your_github_username,password=your_github_password
 
### Publish using a config file
appc cloud publish --git git.config
 
### Contents of git.config
{
  "repo": "https://github.com/jdoe/PublicTestApp.git",
  "branch": "master",
  "access_token": "abce468acbd46f543faa909eedc"
}
 

 

Multiexcerpt
MultiExcerptNameviewlogfiles

View Log Files

An application typically runs in the cloud, so being able to see what is happening in the application is very important. Any log output written to stdout or stderr in the application's root process is captured and stored by Arrow Cloud

Multiexcerpt include
MultiExcerptNamearrow-arrow-cloud
PageWithExcerptDPV:Arrow Products
, and can be viewed using the Appcelerator command-line tool or in the Logs tab of the Arrow Dashboard.

Notes:

  • Only output written by the application's root process is included in the log file; output written by child processes forked by the application's root process will not be caught.
  • Errors such as syntax errors, application crashes and system level failures are logged automatically.

Logging Utilities

The Appcelerator CLI provides three commands for viewing logs for a published application, accessloglogcatloglist.

  • The appc cloud accesslog command lists all requests processed by the Appcelerator Cloud in a specified time period. By default, a maximum of 100 log messages are returned at a time.

  • The appc cloud loglist command lists your published application's log for a specific period. By default, a maximum of 100 log messages are returned at a time.

  • The appc cloud logcat command tails your published application's log continuously from Appcelerator Cloud.

About logged execution times

The execution time reported by the loglist and accesslog commands report slightly different values. The accesslog command reports the time required by Appcelerator Cloud to handle the initial user request, pass it to your Node application for processing, and deliver the response. In contrast, loglist only reports the execution time for your application itself, not including the time required to process the request and response. Consequently, the accesslog execution times are a slightly longer than those of the corresponding loglist log item. For instance, below is accesslog output: 

Code Block
[12/11/2013 08:43:55.790]   127.0.0.1   /   10074ms
[12/11/2013 08:43:23.712]   127.0.0.1   /   10073ms
[12/11/2013 08:43:07.237]   127.0.0.1   /   10073ms
[12/11/2013 08:42:48.365]   127.0.0.1   /   10075ms

And below is the corresponding loglist output.

Code Block
12/11/2013 16:42:028.139 [INFO] [43210] App started
[PERF]  GET / 10069 ms
[PERF]  GET / 10072 ms
[PERF]  GET / 10072 ms
[PERF]  GET / 10066 ms
Multiexcerpt
MultiExcerptNamedependencies

Declare Dependencies

The application can import any third-party modules that are supported by standard Node.js applications. Before publishing the app to the cloud, make sure all dependencies are listed in the dependencies field in the application's package.json file. For example, to add support for MongoDB 1.2.0 or greater:

Code Block
titlepackage.json
{
    "dependencies":{ "mongodb": ">1.2.0" }
}
Multiexcerpt
MultiExcerptNamethirdparty

Third-Party Tools

The Arrow Cloud

Multiexcerpt include
MultiExcerptNamearrow-arrow-cloud
PageWithExcerptDPV:Arrow Products
servers include support for third-party tools, specifically ImageMagick and PhantomJS.

Note
titleMemory Requirements

PhantomJS is memory intensive. At least 1 GB of memory is recommended to use PhantomJS, which requires your application to be run on at least a Large container. For details about changing container sizes, see Application Limitations below.

To use these tools, add the imagemagickphantom and phantomjs node modules as dependencies of the application:

Code Block
titlepackage.json
{
  "name": "FooApp",
  "version": "0.1.0",
  "framework": "none",
  "main": "app.js",
  "dependencies": {
     "imagemagick" : "*",
     "phantom" : "*",
     "phantomjs" : "*"
  },
}

Once you have added these modules as dependencies, use  require()  to access it from JavaScript, then use the module references to make API calls:

Code Block
var imagemagick = require('imagemagick');

imagemagick.identify('favicon.ico', function(err, features) {
    if (err)
        throw err;
    console.log(features["image statistics"]);
});
Multiexcerpt
MultiExcerptNameenvvars

Define Environment Variables

To set environment variables, use the appc cloud config --set <key>=<value> command. To set more than one variable at a time, comma separate the key-value pairs.

You can access the environment variables from the application using the process.env namespace. For example, if you set a variable called foo, use process.env.foo to access it in the application.

To unset an environment variable, use the appc cloud config --unset <key> command.

To check the current environment variables, use the  appc cloud config --env command.

You cannot use the following names for environment variables: "appid", "basedir", "bodyParser", "customConfig", "dirname", "framework", "fullpath", "name", "serverId", "port", "version", "NODE", "NODE_PATH", "PATH", "PWD", "PORT", "TMPDIR", and "USER".

After changing an environment variable, you will be prompted to restart the application.

The following example sets the  foo  environment variables, lists all set environment variables, then unsets the  foo  variable:

Code Block
appc cloud config --set foo=abc
appc cloud config --env
appc cloud config --unset foo
Multiexcerpt
MultiExcerptNamescale

Scale the Application

To customize the number of cloud servers the application can enable the auto-scaling feature to automatically scale up and down the number of cloud servers based on the number of queued requests. You specify the maximum number of queued requests that should occur before the application is scaled up. You can also specify the minimum and maximum number of servers that should be used.

The following example enables autoscaling, using a maximum of five servers, when there are at least 20 queued requests. The application is also configured to automatically scale down the number of servers when the number of queued requests drops below 20.

Code Block
appc cloud config --maxsize 5 MyFirstApp
appc cloud config --maxqueuedrequests 20 MyFirstApp
appc cloud config --autoscaleup true MyFirstApp
appc cloud config --autoscaledown true MyFirstApp
Multiexcerpt
MultiExcerptNamecustomdomains

Custom Domains

Set a Custom Domain and Path

You can bind a custom domain to your application that points to either a CNAME record or A record as well as assign it a path.

The alias to set should be a valid domain name that has been already configured with either a CNAME or A record pointing to the published application's URL. Appcelerator Cloud validates the domain record before binding it to the application.

To bind a domain to an application, use the appc cloud config --set <domain_name> command to bind a domain to the application. You can bind multiple domains to an application. Use the --set <domain_name> parameter to bind up to five additional domains to the application.

If you need to remove a domain, use the --remove parameter. For applications with multiple domains, you will be prompted to select which domain to remove. You may optionally pass the domain name to remove with the --remove parameter.

To route an application based on a path with the domain name, use the appc cloud config --path <path_name> command to set a path for the application after setting a domain. For example, if you want to bind two applications to the same domain, specify a path for each to route a client to the correct application.

The following example allows the application to be accessed from  www.foo.com  :

Code Block
appc cloud domain --set www.foo.com

The following example allows the LegacyApp application to be accessed from   www.foo.com/v1   and the BrandNewApp application to be accessed from   www.foo.com/v2  :

 

Code Block
appc cloud domain --set www.foo.com LegacyApp
appc cloud domain --path v1 LegacyApp
appc cloud domain --set www.foo.com BrandNewApp
appc cloud domain --path v2 BrandNewApp

Wildcard Subdomains

The pre-defined  cloudapp.appcelerator.com  URL that Appcelerator Cloud uses to publish your application supports a wildcard subdomain. You may append a token to the beginning of the URL that can be parsed by the application. This does not apply to custom domain names using the acs domain command to bind the application to a CNAME or A record.

For example, if your published URL is  https://1234567890.cloudapp.appcelerator.com/ , you can navigate to your application using the same domain and add a custom token as the subdomain, for example,  https://deadbeef.1234567890.cloudapp.appcelerator.com/ , where deadbeef is the wildcard subdomain. Then, the application can retrieve the host and subdomain:

Code Block
var http = require('http'),
    url = require('url');

http.createServer(function (req, res) {
    var host = req.headers['host'],
        subdomain = host && url.parse('http://'+host).hostname.split('.')[0];
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Your host is: ' + host + '. Subdomain is: ' + subdomain);
}).listen(process.env.PORT || 8080);
 

...

Multiexcerpt
MultiExcerptNameapplimits

Application Limitations

Diskspace

Each application can use 1.8 GB of diskspace. The application can only write files to the project's root directory and to the /tmp folder.

Server Containers

Each application runs in a specific container size with different resources (memory and number of CPUs). By default, when the application is published, it will run in one Dev container.

  • To specify a bigger container for the application, use the appc cloud server command.
  • To use more than one container for your application, enable auto-scaling with the appc cloud config command.

You can specify one of the following container sizes depending on your Appcelerator Platform subscription:

NamePoint CostMemoryCPUsArchive Behavior
Dev1256 MB1After an hour of inactivity
Small2256 MB1After a week of inactivity
Medium4512 MB2After a week of inactivity
Large81024 MB4After a week of inactivity
XLarge162048 MB8After a week of inactivity

If your application gets archived, to reactivate the application, make a request to it. The first request will be slow, but subsequent requests will respond with normal speed.

Note that each container your application runs on costs a certain number of points. To see how many points you have used and are allocated, or to see which containers your application is using, execute the appc cloud list command.

Code Block
$ appc cloud list MyArrowApp
ACS: Appcelerator Cloud Services Command-Line Interface, version 1.0.23
Copyright (c) 2012-2015, Appcelerator, Inc.  All Rights Reserved.
Admin Hostname: https://admin.cloudapp-enterprise-preprod.appctest.com

============ 
Points:
 -- Quota: 17
 -- Used: 16

App name: MyArrowApp
 -- Created by: joeuser@appcelerator.com
 -- URL: https://myapp.cloudapp-enterprise-preprod.appctest.com
 -- Created at: Mon Mar 23 2015 21:58:36 GMT-0700 (PDT)
 -- Node Version: 0.10.22
 -- Server Size: XLarge
 -- Maximum allowed number of servers: 1
 -- Desired minimum number of servers: 1
 -- Active version: 1.0.0
 -- Published at: Thu Mar 26 2015 13:54:07 GMT-0700 (PDT)
 -- Status: Deployed

 

Server Ports

Currently, Arrow Cloud

Multiexcerpt include
MultiExcerptNamearrow-arrow-cloud
PageWithExcerptDPV:Arrow Products
only supports applications opening one server listening port. There cannot be more than one TCP/HTTP server started in one application.

 

...