{"__v":26,"_id":"54cfbd635ff7e617002bbd90","category":{"__v":4,"_id":"54cfb99bbba1a023008741af","pages":["54cfbacd5ff7e617002bbd8a","54cfbd635ff7e617002bbd90","54cfbf6e3995cf0d0006f6fc","54cfc0b0bba1a023008741c9"],"project":"54cf411f9d09bb0d00a17a1c","version":"54cf411f9d09bb0d00a17a1f","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-02T17:53:31.393Z","from_sync":false,"order":0,"slug":"getting-started","title":"Getting Started"},"parentDoc":null,"project":"54cf411f9d09bb0d00a17a1c","user":"54cfa8c8a8a4fd0d00b7fd1c","version":{"__v":14,"_id":"54cf411f9d09bb0d00a17a1f","project":"54cf411f9d09bb0d00a17a1c","createdAt":"2015-02-02T09:19:27.656Z","releaseDate":"2015-02-02T09:19:27.656Z","categories":["54cf41209d09bb0d00a17a20","54cfb99bbba1a023008741af","54cfb9a65ff7e617002bbd7f","54cfba03bba1a023008741b6","54cfba0ebba1a023008741b8","54cfba19bba1a023008741b9","54cfba29bba1a023008741bb","54cfba345ff7e617002bbd87","54cfba3ebba1a023008741bc","54cfba473995cf0d0006f6f0","54e371b18ef7552300409bf2","54e37aa5e887c50d005ef629","555a4e9b147f91190092d137","56b0e91802f4bc0d006ce254"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["55b0acb2b3171b3700b15385","5666ab895d7f5f1700ae10ed","566deac55989ba0d00e3e8b8","56a346ed5e57f20d000eadf7"],"next":{"pages":[],"description":""},"createdAt":"2015-02-02T18:09:39.382Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"On Hosted and SSH workspaces, Cloud9 provides two ways to run your application:\n\n  1. Using the Run panel with built-in Runners for many languages\n  2. From a Terminal \n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Available ports on a hosted Cloud9 workspace\",\n  \"body\": \"If you're developing a server application, please note that you need to listen to 0.0.0.0 ($IP) and 8080 ($PORT). Listening to this port will enable your app to be viewable at http://<workspacename>-<username>.c9users.io\\n\\nYou can also bind to ports 8081, and 8082, which can be accessed by http://<workspacename>-<username>.c9users.io:8081 and http://<workspacename>-<username>.c9users.io:8082 respectively.\\n\\nPlease note that 8080, 8081, and 8082 are the only available ports on a hosted Cloud9 workspace.\"\n}\n[/block]\n# Method 1: Use the Run panel\n---\n\nFirst, open the file you want to run.\n\nNext, click on the Run button in the top menu bar in the IDE.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/YZ5LnkdR0ekVjWEfPcMg_Screen%20Shot%202015-02-18%20at%207.48.36%20AM.png\",\n        \"Screen Shot 2015-02-18 at 7.48.36 AM.png\",\n        \"644\",\n        \"38\",\n        \"#61a4d1\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThe Run button acts as a sort of shortcut to the Run panel, which will appear by default in the bottom of the IDE when you run a file. This automatically runs the currently active file, and it will guess which Runner to use based on the extension of the file.\n\nWhen you're ready to stop your app, click on the Stop Button button in the menu bar at any time, or from the Run panel below.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Z8m3NbqCR2CrZw2KeNug_Screen%20Shot%202015-02-18%20at%207.50.06%20AM.png\",\n        \"Screen Shot 2015-02-18 at 7.50.06 AM.png\",\n        \"1080\",\n        \"39\",\n        \"#abb3c2\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nOn the Run panel, you'll notice a few more options you can set. Filling these textboxes out creates a Run Configuration.\n\n  * Name: the name of your run scenario\n  * Command: the command you want to run; this is usually the location of your running file in your project, but it also allows you to provide any additional command line arguments you want to pass to your app\n  * Runner: defines how you want your code to be run. A wide range of Runners is available by default, from Apache to Node.js and Shell scripts, and you can define your own.\n  * CWD: Set the current working directory to start from\n  * Environment: Set environment variables\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"If you can't find the Runner you need from the default set, you can create your own [custom runner](doc:custom-runners)\",\n  \"title\": \"Custom Runners\"\n}\n[/block]\nFor some default runners like Node.js, it's an option to Run in debug mode, which indicates that you want to run the current code through the debugger. This will reveal (or collapse) the debugging tools panel described in Running and Debugging your code.\n\n# Method 2: From the Terminal\n---\n\nThe built-in Terminal provides access to all underlying system commands, including your Runners such as Node.js. Simply open up a Terminal from the \"+\" sign, or use CMD+T (Mac) / Control+T (Windows), and then execute the command you need to run your app, e.g. `node server.js`.\n\n# (Pre)View Your Application\n---\n\nTo find out where your application is running you can do two things:\n\n  1. Use the Preview button on the top to preview one of your files. The URL in the browser bar in the Preview can also be used in any browser tab/window.\n  2. Use the Share button on the top to figure out the URLs of running Application and the Preview. The Editor URL is only used to share your entire Cloud9 workspace to collaborate on code.\n\n## Environment variables\n\nMake sure to use the environment variable `$PORT` in your application so that you can preview your application. For example, in an node.js application you would use `process.env.PORT`, in a python application that would be `os.environ['PORT']`. \n\nCurrently `$PORT` defaults to 8080 but this may change in the future.\n\nTo add other environment variables, you can click the `ENV` button on the far right side of the run menu and add the variable name and value.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Tip: If you can't find how to preview your running app, try to use port 8080 in the URL.\",\n  \"title\": \"\"\n}\n[/block]\n## Related\n[Why does my app stop after a couple hours/days?](doc:inactive-workspaces)\n\n<div style=\"text-align: center;\"><a target=\"_blank\" href=\"https://community.c9.io/t/documentation-run-an-application/1453?utm_source=docs.c9.io&utm_medium=article&utm_campaign=Docs%2BFeedback\" class=\"button info solid\">Submit feedback or questions about this page</a></div>","excerpt":"","slug":"run-an-application","type":"basic","title":"Run an Application"}

Run an Application


On Hosted and SSH workspaces, Cloud9 provides two ways to run your application: 1. Using the Run panel with built-in Runners for many languages 2. From a Terminal [block:callout] { "type": "info", "title": "Available ports on a hosted Cloud9 workspace", "body": "If you're developing a server application, please note that you need to listen to 0.0.0.0 ($IP) and 8080 ($PORT). Listening to this port will enable your app to be viewable at http://<workspacename>-<username>.c9users.io\n\nYou can also bind to ports 8081, and 8082, which can be accessed by http://<workspacename>-<username>.c9users.io:8081 and http://<workspacename>-<username>.c9users.io:8082 respectively.\n\nPlease note that 8080, 8081, and 8082 are the only available ports on a hosted Cloud9 workspace." } [/block] # Method 1: Use the Run panel --- First, open the file you want to run. Next, click on the Run button in the top menu bar in the IDE. [block:image] { "images": [ { "image": [ "https://files.readme.io/YZ5LnkdR0ekVjWEfPcMg_Screen%20Shot%202015-02-18%20at%207.48.36%20AM.png", "Screen Shot 2015-02-18 at 7.48.36 AM.png", "644", "38", "#61a4d1", "" ] } ] } [/block] The Run button acts as a sort of shortcut to the Run panel, which will appear by default in the bottom of the IDE when you run a file. This automatically runs the currently active file, and it will guess which Runner to use based on the extension of the file. When you're ready to stop your app, click on the Stop Button button in the menu bar at any time, or from the Run panel below. [block:image] { "images": [ { "image": [ "https://files.readme.io/Z8m3NbqCR2CrZw2KeNug_Screen%20Shot%202015-02-18%20at%207.50.06%20AM.png", "Screen Shot 2015-02-18 at 7.50.06 AM.png", "1080", "39", "#abb3c2", "" ] } ] } [/block] On the Run panel, you'll notice a few more options you can set. Filling these textboxes out creates a Run Configuration. * Name: the name of your run scenario * Command: the command you want to run; this is usually the location of your running file in your project, but it also allows you to provide any additional command line arguments you want to pass to your app * Runner: defines how you want your code to be run. A wide range of Runners is available by default, from Apache to Node.js and Shell scripts, and you can define your own. * CWD: Set the current working directory to start from * Environment: Set environment variables [block:callout] { "type": "info", "body": "If you can't find the Runner you need from the default set, you can create your own [custom runner](doc:custom-runners)", "title": "Custom Runners" } [/block] For some default runners like Node.js, it's an option to Run in debug mode, which indicates that you want to run the current code through the debugger. This will reveal (or collapse) the debugging tools panel described in Running and Debugging your code. # Method 2: From the Terminal --- The built-in Terminal provides access to all underlying system commands, including your Runners such as Node.js. Simply open up a Terminal from the "+" sign, or use CMD+T (Mac) / Control+T (Windows), and then execute the command you need to run your app, e.g. `node server.js`. # (Pre)View Your Application --- To find out where your application is running you can do two things: 1. Use the Preview button on the top to preview one of your files. The URL in the browser bar in the Preview can also be used in any browser tab/window. 2. Use the Share button on the top to figure out the URLs of running Application and the Preview. The Editor URL is only used to share your entire Cloud9 workspace to collaborate on code. ## Environment variables Make sure to use the environment variable `$PORT` in your application so that you can preview your application. For example, in an node.js application you would use `process.env.PORT`, in a python application that would be `os.environ['PORT']`. Currently `$PORT` defaults to 8080 but this may change in the future. To add other environment variables, you can click the `ENV` button on the far right side of the run menu and add the variable name and value. [block:callout] { "type": "info", "body": "Tip: If you can't find how to preview your running app, try to use port 8080 in the URL.", "title": "" } [/block] ## Related [Why does my app stop after a couple hours/days?](doc:inactive-workspaces) <div style="text-align: center;"><a target="_blank" href="https://community.c9.io/t/documentation-run-an-application/1453?utm_source=docs.c9.io&utm_medium=article&utm_campaign=Docs%2BFeedback" class="button info solid">Submit feedback or questions about this page</a></div>