How to access Bluemix application's runtime shell as root? - node.js

I have a Nodejs application running in Bluemix. I try to run a command to install dependencies in Nodejs application container. I accessed it using application's runtime SSH. I need root privileges to install dependencies. It is asking me password for sudo command. How can i get that password?

You shouldn't be installing dependencies this way. The ssh terminal is intended for debugging purposes only:
If you need to troubleshoot an instance of an app, you can gain SSH
access to the app using the SSH proxy and daemon.
For example, one of your app instances may be unresponsive, or the log
output from the app may be inconsistent or incomplete. You can SSH
into the individual VM that runs the problem instance to troubleshoot.
Source: https://docs.cloudfoundry.org/devguide/deploy-apps/app-ssh-overview.html
NodeJS dependencies can be installed by adding a package.json file:
Cloud Foundry expects a package.json in your Node.js app. You can
specify the version of Node.js you want to use in the engine node of
your package.json file.
In general, Cloud Foundry supports the two most recent versions of
Node.js. See the GitHub Node.js buildpack page for current
information.
Source: https://docs.cloudfoundry.org/buildpacks/node/node-tips.html

Related

Run NodeJS command on Azure

I am fairly new to NodeJS development. I have no issues whatsoever running commands on my local machine. For instance, say I want to install a package called "formidable" on my Node server, I'd run the command 'npm install formidable'. If I have deployed my NodeJS application to Azure, how would I run the same command?
NB - I do not want to manually run the command on my local machine and then deploy to Azure. This will take far too long, since I have to install many packages each with many files in them.
Please advise on how I go about doing this?
Thanks
Beside login KUDU console site and run command in online cmdlet. You also can configure dependencies in package.json, then you deploy your nodejs application to Azure via GIT, it will automatically install the dependencies in this file.
For example:
You add the formidable module in dependencies:
Then deploy it application on Azure Web Apps, you can see the remoting deployment logs in cmdlet that the module was added in the application on Azure, e.g.:
You can refer to Create a Node.js web app in Azure App Service for how to create a nodejs application and deploy via GIT.
If you are running an Azure Web App you can use Kudu Services.
To do this
browse to http://yoursitename.scm.azurewebsites.net
It will ask you to authenticate if you have not already
Click on Debug Console -> CMD
You can run your npm commands from there.
Screen shot below
More information can be found here: https://github.com/projectkudu/kudu/wiki

Node app management complaining about missing start script

I have a node.js app that is pushing successfully into bluemix.
I'm trying to use the App Management feature.
But when I push I get the following warning.
WARNING: Avoid semver ranges starting with '>' in engines.node
WARNING: App Management cannot be installed because the start script cannot be found.
My start script is located in Procfile at my project root and contains which is starting my project ok.
web: gulp serve:prod
I tried putting a start command in package.json but still had this same warning. How can I get App Management installed?
App Management in the IBM Node.js buildpack currently only supports applications that are started using the node executable with a JS file. For example,
node [opts] server.js [args]
This is because many utilities in App Management are dependent on being able to manipulate the start command. For example, to start the application with inspector enabled, we need to be able to set the debug port (--debug $PORT).
Due to this limitation, App Management is not supported if your application uses gulp or similar build automation systems to start your application.

How to deploy a socket.io from nodejs on Tomcat

Here's the thing, I have a folder, using Nodejs and socket.io(it's a chat) and I also have a server running Tomcat 8. I have worked with .war and .ear files before in Tomcat, but I'm new in this nodejs deployment thing.
Do you guys have like a tutorial or can you explain me how can I like package my app and then deploy it, or upload the folder, I don't know, something.
You don't need tomcat to run your node.js application. Just be sure node is installed on your server and the port you are using is allowed on your server's firewall and you are good to go. (Don't forget to install your npm packages through your packages.json of course)
Usually a node.js app is run like below;
node server.js
And that's all. If you'd like to keep it alive or restart in any case of issue you can use forever (https://www.npmjs.com/package/forever)
If you want to load balance with reverse proxy or if you want to configure ssl etc. you can use nginx or haproxy etc.
If you want to automate your deployment you can create a hook to your git source (github, bitbucket etc.) and write down a script to stop / start your node processes, fetch modified files, install npm packages etc.

How to use simple npm-install in Openshift?

I'm trying to use cute-files on my openshift account
https://www.npmjs.com/package/cute-files
I know node.js works as I did in localhost:3000 but not as expert,
I'm ended up with http://cutefiles-powerupware.rhcloud.com/ that's not I'm looking it. It should be Cute-files app as start.
I did PuTTY to access terminal to do npm-install but no luck due to permission.
The problem is... I cannot understand how openshift works, I need to know how to access console to do npm-install then, execute "$ cute-files", alternativley I've used Git to commit and push, the files are updated...I got no results... I've spent like 6 or 7 hours, Openshift has been very complicated me to use, can anyone explain how to install and execute simple node.js app in openshift?
It's not like you can access Openshift and run any command. Openshift isn't a simple hosting or vps service, it's a PaaS. That means they offer you an environment to run certain services in particular as you demand.
When you create an app it's bound to a git repository which when pushed will be deployed to openshift.
About your application being deployed and runned, it's NOT about node.js running in port 3000. Openshift has some default application file names and port to expect.
So, working in a local clone of such repository you might perform the npm install command, that will download the node_modules folder to be there.
How to do all this?
First you should install rhc in your system.
Manage to clone any of you applications via rhc.
Make changes, and do git.
Those changes may include doing npm install getting your dependencies.
When doing git push, expect the changes to be deployed.
You really should read this guide.

Deploy sails.js to Windows Azure Website

I'm following this guide on installing a node.js application on Azure:
http://www.windowsazure.com/en-us/develop/nodejs/tutorials/create-a-website-(mac)/#header-0
Is it possible to get a sails.js app running without having to instantiate a Virtual Machine?
New guide on deploying to Windows Azure:
https://github.com/mdrmuhaimin/sails-docs/blob/b1030c21daf885e6490e1d1f946375a5c8584e4c/Guide:Deploying-Sails-to-windows-azure-linux-vm.md
Also, as I mentioned in the comment above, you don't have to install Sails globally to deploy it-- just clone your app, run npm install, and then forever start app.js or node app.js. See the deployment guide for more info.
As of right now sails requires an npm install -g on the box which would require either a virtual machine or a cloud service with a startup script. The link you are showing if for a deployment model where you don't get any access to manipulate the host since there are many instances running on it.
It would be great if sails could be included inside an app by putting it in the package.json and started up from within the app.
UPDATE - This has changed since the answer was posted. #mikermcneil has an updated answer that reflects the current state.

Resources