Should I use special user for pm2 to run my express app? - pm2

Does it make sense / is it absolutely essential to run pm2 through a special dedicated user on linux host? I want to run my express app and restart it whenever it crashes. From nginx/apache I am used to having special users that run the processes. It introduces obviously some hassle with permissions. But in almost no tutorials / articles do I see people making the effort of creating a new user and using it to run their express apps. More over, it looks like pm2 is running as root daemon on the system, is that true, or did I configure it wrong?
Thanks

Related

i would like to know few things about how to host and upload full website include(server ,react, mysql)

Finally i completed my first full project using server, client, data
i would like to know few things about how to host and upload full website include(server ,react, mysql)
i so wondering how that is work, for now i understand that to upload a simple website you need a domain and to hosting, just do npm run build and upload it..., this is something that i know but, when that is not just a simple website like
when i have such as
server side with Node.js + express that have requests (on localhost) *probably need to change the localhost to something else but what
Database running with MySql
React app that have many request to (localhost)
how can i hosting all of them and running my website for everyone, i mean that my sql will still running, CRUD Data will update normal, and the server will still get request and send or update them to mysql data.
and if I'll want to make some change on mysql, server, client
i want to change it like i change it now
Actually i'm not a FullStack developer if i don’t know it... 🥶 so i really interesting to understand all of that issues
i hope you guys havק An understandable answer for me, thanks 🙏 and just take your time :)
Well, where to start hehe. There are a lot of different ways to host a web app. Heroku for example makes this process really simple.
Personally, I use Digital Ocean to host my apps. This is generally how that goes:
I have a project with a folder structure that seperates the server logic and the client logic.
Since you're using Node, you build your client with npm run build. Next make sure the dist/build folder is inside your server folder. That is the folder you are going to 'host'. On Digital Ocean, you make a new droplet (which basically is just a tiny part of a server).
You install Node, Git, Pm2 and (for example) Nginx. You clone your project from Github to the server and install all the dependencies.
You have to do a few configurations with nginx (specifying a domain name for example) to make everything work. This article goes into more detail about that.
Also, a database is frequently hosted seperately. You should read more about that.
If you have everything setup, you can just code on your project as usual. Push new updates to github, and pull in the changes on the server.
Here is another post on Stackoverflow talking about hosting MySql with react.

Does ClojureScript project need a process manager?

I want to start a project that using Node.js+Express.js+ClojureScript in light of https://gist.github.com/jneira/1171737 . But I am afraid that if I deploy the project to production environment, it should be protected by a process manager, like pm2 in a Node.js project.
As far as I know, pm2 is needed by a Node.js project because that Javascript in Node.js is single-threaded, so exception will cause Node.js apps to halt. pm2 will protect the app and make it running forever.
But does a ClojureScript project running in Node.js need a process manager? If so, how should I do the work like pm2?
Thanks!
As ClojureScript compiles to javascript there is no difference in the tooling you can use to manage the node.js process. You can just follow the normal pm2 instructions if you want to use pm2. If you are running a web server I'd suggest you also check out passenger.
And on the actual need to use a process manager, and which manager to use in that case: Those are depending a lot on personal taste / opinion.

Provide Shell in a HTML page of that Web Server

I have a Linux based Web Server running Fedora. I have created and hosted couple of HTML pages on that.
I have info providing CLI tools that run on this server but must be accessible to all users from their browsers
I haven't started and these are my requirements
How do I provide that servers shell (BASH) via HTML page? What are the softwares that make it possible?
Can I provide auto-login enabled shell?
I just want to avoid multiple users having to open SSH sessions to the server. Also I can provide instructions and terminal access hand in hand using HTML pages.
ShellInABox appears to provide a colored terminal interface to browsers via Ajax. (homepage) Since it runs as a separate webserver, you may need to link your users to a different port on your site. There are surely more alternatives (other projects like this) out there.
The following advice applies regardless whether you use ShellInABox or continue to provide ssh access.
If you don't fully know and trust all your users, then assume at least one of them is a whizzkid cracker, determined to crash or break into your system. The first thing he may try to do is log in and run a forkbomb.
You should therefore do your best to sandbox users, so they cannot harm the system or each other. Restrict their access privileges (file/folder/network access) to only what is needed to achieve the tasks you allow. SELinux and AppArmor have facilities for this. You can find some more sandboxing techniques here and here. Docker is a new system that may be worth investigating.
It would be very wise to host your login server on a separate or virtual machine, distinct from your main webserver, so that any user who does manage to break out of the sandbox will not be on the same machine as your other services. (But note he will still be inside your LAN!) User-mode-linux is a less secure alternative and chroot is worse still, but better than nothing!
If users should be able to save files, then I would recommend giving each user a separate account, especially if their files should persist between sessions. Of course, as a workaround for auto-login you could provide a guest account with password guest555 for all users, but then a malicious user could bother others by deleting files or putting nasty stuff in the shell startup scripts. (I certainly don't recommend guest/guest because crackers regularly scan the net for ssh servers hosting that account!)

Development environment Sinatra & MySQL in 2 computers

I'm developing a Sinatra and MySQL application. I'm using as development environment a Macbook Air and an iMac. The server runs on a FreeBSD VPS running unicorn behind nginx.
I'd like to somehow automate the whole procedure, I develop in both iMac and MBA. Depends on time I have free in the office (MBA) or time I spend writing code at home (iMac). I have setup MySQL on both macs.
I manually dump and restore the database in order to be able to test my application locally before making any change to the server.
I'd like to automate the process of: Syncing the MySQL database if possible, keep the code up-to-date to all locations without using cloud storage if possible.
Best Regards,
I think there are many ways to solve this problem.
So this is just on idea how to achieve this.
Create a git repo on your server and write a small shell script which sync your db from somewhere. This script can you trigger by a git hook http://git-scm.com/book/en/Customizing-Git-Git-Hooks#Client-Side-Hooks
For your syncing script you may have a look at this -> https://github.com/xssnark/mysql-db-sync or I'm sure you find something.

Comet (Ajax Push) in Godaddy dedicated server?

I want to know if it's possible and I'm looking for tutorials to set it up.
APE website says that knowledge of JavaScript programming is sufficent to follow the tutorial however I haven't been able to puzzle even the first 2 lines of the tutorial.
I'm using Ubuntu. After downloading APE I have no idea what to do. I already set up SSH to access the server.
What should be my following steps or where can I find an easier to tutorial to use comet be it through APE or something else?
Assuming your GoDaddy server is running some flavor of Linux, I don't see any reason it would not be possible. I was just looking over the documentation and I am not clear on what part you are having trouble with. What Linux distribution are you using? Do you have SSH access?
If you have ssh access and a root account you should be able to just follow the instructions to get APE running on the default port.
If you are running a Debian dist (Ubuntu and others) it looks like you should download the source from Git and compile it. There are instructions for the compilation there. You can learn about what you need to do wth Git by search for "clone git".
If you can be more specific about what you are having trouble with, we can probably be more helpful. But ultimately you should be able to install this on any dedicated server without issue.