How to use binary executables in cron tab on web hosting - c++

I use a web hosting (leadhoster.com) for my website and I use cron tab to run my PHP script on regular basis. But I need my script work much faster, as it processes images, so I want to write it in C++.
But how is it possible to create binary executable on a web hosting? I did not find CC or gcc compiler on the hosting. Should I install same version of Linux on my home computer and build my code there to prepare binary executable? How this kind of things is usually done?

They won't appreciate it, if it's even possible. Most shared hosting providers disable all this access, since it's a major security risk.
You could install the same linux they're using and compile it there. You will probably need to build a fat statically linked binary, since you probably can't install libraries either.

The only people who can help you with this as leadhoster's support group. They will most likely tell you that you can't do it on a shared server.

Related

How can you find out Azure-pipeline image content?

I'm new to Azure-Pipeline and struggling to put together a C++ oriented pipeline that uses camke which properly compiles, run tests and build documentation on Ubuntu, macOS, and Windows.
I managed the macOS and Ubuntu cases rather easily but am struggling with the Windows case not knowing what's installed and what's in system PATH for the given image & container I've selected.
Not being super familiar with the Azure-Platform I'm basically relying on commit-push-run-pipeline every single little change to my YAML file thus wasting time and resources.
I can't imagine that the only way is to blindly try out commands by commit, push and run the pipeline.
I managed to find a basic description of the currently (hopefully) available images here following the included software link for Windows link yoou end up on a comprehensive list of what's supposedly installed (I have some doubts on whether this documentation actually matches the content of the image). Calling some of those tools like cmake and choco, present in the above list, failed. Whether or not they're actually installed and in system PATH I have no idea.
Q1: Is there any way to locally test out an Azure-Pipeline YAML?
Q2: Is there any way to figure what is actually installed on a given image/container (without issuing a DIR /s from the root folder??)
Q3: Is it possible to connect to a running container (or is it a VM???) instance and directly tinker with it?
Q4: Alternatively, is it possible to run such an image locally (Docker)? Does it imply execution on a Windows machine or is that a standalone VM image?
EDIT: Found out about this question, although doesn't quite answer mine: Is there a tool to validate an Azure DevOps Pipeline locally?
Q1: Is there any way to locally test out an Azure-Pipeline YAML?
The answer is yes. You could create your private agent to execute the Azure-Pipeline YAML.
Self-hosted agents
Q2: Is there any way to figure what is actually installed on a given
image/container (without issuing a DIR /s from the root folder??)
Just as you know, we could check the document Software for the software installed on the agent. If you want to know the install the path of some software, you could check the debug log from the build task. For example, cmake. We could check the build log from the cmake task:
Q3: Is it possible to connect to a running container (or is it a
VM???) instance and directly tinker with it?
For the hosted agent, I am afraid the answer is not.
Q4: Alternatively, is it possible to run such an image locally
(Docker)? Does it imply execution on a Windows machine or is that a
standalone VM image?
The answer is yes, we could Run a self-hosted agent in Docker. And it imply execution on a Windows machine.

Manager local repository

I come from Java world. I was looking for Apache Maven alternative in C++ world. I think I found the correct project. I have few questions and have not managed to find an answer.
Is it possible to manage local repository. Let's say, I work on 5 similar but different projects and this project share mostly the same dependencies. Will each project have it's own dependencies stored inside each project or is there a "system" wide (per user) local repository where dependencies are stored?
Is it possible to "publish" only to local folder so other project can "see" dependent block or it has to go over bii internet repository?
Or am I wrong - about how bii works.
Looks nice project. Keep up the good work.
Right now, projects act as virtualenvs, each project contains and build its dependencies. This is intended for fast evolving libraries. Imagine you have 5 similar projects all depending on the same library A, version 0. While working on one of those projects you can make a modification to A and publish a new version, an API breaking modification. The other 4 projects will continue depending on version 0, and will not break. When you move to those projects you can easily update their dependencies and fix the breakages.
You can share the same library among different projects straight ahead with sym links if working in linux, not working by now in windows.
For very stable, large projects that can be installed system-wide, it could be more convenient to depend on the installed version. CMake allows this very easily via FindXXX(). You can install system wide the binaries with CMake install, or you can even use CMake scripts or biicode python hooks to automatically download and install system wide those libraries. Check, e.g.:http://www.biicode.com/diego/opencvex, OpenCV is managed with a biicode python hook and installed system wide.
At this moment there is no "local" publication, and if you want to share that way among projects, yes, you have to go over the biicode cloud servers, simply with "bii publish".
However, we are transitioning to open-source. We will probably release first the client code, then we will release a server that could be deployed in-house. Not implemented yet, but a future feature is that this server could act as a proxy to the cloud one, you can publish to the local instance, but read from the cloud one. With a local installation of this server, you will be able to publish locally.

Try to install django-cms in a shared host

can I install django-cms(from www.django-cms.org) in a shared hosting without shell access? Thanks very much!
The real question is: "Can I run Django in a shared host?". django-cms is just package, it needs Django to run and Django is likely going to be your limiting factor there, not django-cms.
So, the answer to that is a resounding "Maybe". Technically, if you run all your Python packages in a virtualenv, including Django and django-cms, you shouldn't need root/sudo privileges. But, and it's a big but, that assumes your shared hosting provide makes virtualenv available to you. If they support Python at all you should be good, but even then, who knows.
However, shared hosting is really not appropriate in general for anything like Django. Even if you can get it to run, performance will surely be an issue. Nowadays, there's really zero reason not to just jump to a VPS. You can get your own little VPS over at Rackspace for ~$11/mo. That's cheap -- like possibly cheaper than what you're paying for shared hosting cheap.
Just make the leap and stop living in limited shared environment. It's worth every penny.

Django Compressor on a multi-server deployment

I've been fortunate enough to discover django_compressor and implemented it within our stack, which deploys to many servers (Currently 6, but growing as we deploy smaller virtual machines.)
Now this is all fine and dandy if you're using django_compressor at its finest. Compressing raw CSS/JS code
However, say now I want introduce some type of pre-compiler. Let's say for this example it is LESS (css). The thought process for this is fairly simple:
Install node, npm, and the less package onto the server.
Add less to your precompilers!
COMPRESS_PRECOMPILERS = ( ('text/less', 'lessc {infile} {outfile}'), )
Now you deploy, and your server compiles the less file. Everything is fantastic!
Now let's add 8 more servers to that and you have to install node, npm, and less on each server?
This is where something doesn't seem right, and I feel like I'm missing something. I believe the Django community has run into this problem before.
My thoughts thus far have been:
Use a post-commit hook to compile the CSS on the developers machine. This means that via django_compressor, we link to the compiled static file in the HTML, and our repository contains both the compiled and non-compiled versions. My only downside to this is it ends up not using half of the benefits of django_compressor and may be tedious for developers?
Suck it up and make node, npm, and less part of the server stack.
Update
I did some additional looking around and it seems that using the COMPRESS_OFFLINE flag (or just --force) with the management command will produce an offline manifest file that does what I need (only tested locally). So setting this up with a pre-deploy hook likes to be the answer.
Of course, still open to other ideas :-)
Coupled with the tips in the comments about COMPRESS_OFFLINE, you could look at django-staticfiles' storage stuff. You can host the static files on amazon s3, for instance, so hosting it all on one static-hosting server and using that from all your servers could also be a nice solution. You wouldn't need to do anything with the static (and compressed) files on the individual servers.
Alternative solution regarding the multiple servers: I've made a custom fabric (docs.fabfile.org) script that installs/configures stuff on our servers. I've only recently started using coffeescript and less, but those two are definitively ending up in my fabfile. That solves the installation problem for me.
(Alternatives to a fabfile are things like a custom debian package with standard dependencies. Or chef or puppet or something similar.)
you can use puppet for the task

How can I encrypt my django code?

I have to upload my django project to a shared hosting provider.
How can I encrypt my code?
I want to hide my code on the server.
Thanks :)
You can't. You could upload .pyc files I suppose, but they are completely and utterly trivial to decompile.
Who are you trying to conceal it from? If it's other users on the shared system, then make sure you have directory permissions properly restricted to your user. If it's the shared hosting provider itself, then there's not much you can do since obfuscation won't buy you all that much; spend some time to find a reputable hosting provider you can trust.
If you really want to hide your code, you have to build custom python interpreter that uses different opcodes (in python bytecode). Then the server only has your hacked binary and pyc's that are not trivial to decode. You can add encryption on top of that, or at least sign your code so that your binary is not that easy to investigate.
Another possibility is to never have your code on disk, only keep it in RAM. You could start your server process via e.g. execnet.