The Core Technologies Blog

Our Software // Windows Services // 24×7 Operation


Q&A: Why Doesn’t AlwaysUp Restart my Application?

Q&A: Why Doesn't AlwaysUp Restart my Application?
  My company uses AlwaysUp to run 4 applications on our lab server. Every few weeks, one of the applications stops running and I have to log in and restart it. Why doesn’t AlwaysUp automatically restart it?

Here is what I see in the logs:

AlwaysUp not restarting: Activity

— Sandy

Hi Sandy, thanks for reaching out. The whole point of using AlwaysUp is to keep your application running 24/7/365 so you are right to be puzzled!

Before digging into the details, let’s review the basics of AlwaysUp.

How AlwaysUp works (a quick summary)

When you configure an application in AlwaysUp, a true Windows Service is created. Let’s call it the AlwaysUp service.

For example, if you setup Dropbox in AlwaysUp, you will see an AlwaysUp service called “Dropbox (managed by AlwaysUpService)” in the Services utility:

Dropbox (managed by AlwaysUpService)

When your computer boots, the AlwaysUp service:

  1. Starts before anyone logs in

  2. Launches your application

  3. Constantly monitors your application, quickly restarting it if it crashes or dies for any reason.

The AlwaysUp service is the key to running your application 24×7.

(If you are curious to find out more about the inner workings of AlwaysUp, check out our detailed How AlwaysUp Works explainer.)

What your logs tell us

The activity report shows AlwaysUp running your application continuously for a few days. Then at 7:03:11 AM, your application suddenly stops. And soon after, the AlwaysUp service stops as well.

Your application is not crashing or failing in any way. No errors or warnings were reported and nothing out of the ordinary occurred.

From that benign sequence, we can conclude that someone (or something) intentionally stopped your AlwaysUp service.

And with the service stopped, the only way to restart your application is to restart the AlwaysUp service.

Who stopped your AlwaysUp Windows Service?

Unfortunately the logs don’t say who (or what) stopped the service.

However, there are at least 4 ways that the service could have been stopped:

  1. From the Services application.

    For example, clicking the Stop button will terminate the AlwaysUp Dropbox service:

    Stop the service
  2. With the NET STOP command.

  3. With the SC STOP command.

  4. From an application leveraging the Windows Services API.

Do you know who would stop the service?

Are there any batch files that manipulate services?

Watch out for maintenance scripts and other background tasks.

Investigate with Windows Service Auditor

If it’s time to put your detective hat on and figure out who’s stopping the service, our free Windows Service Auditor tool should be able to help. It will record all operations performed on the AlwaysUp service.

After downloading and starting Windows Service Auditor, enable extended auditing for the AlwaysUp service. Periodically review the service’s security events, watching for “Stop the service” operations, like this:

Windows Service Auditor: Stop event

Good hunting!

Keep the service running with Service Protector

If you are unable to prevent the service from shutting down, consider deploying Service Protector as a second layer of defense.

Install Service Protector, select Protector > Add and choose your AlwaysUp service from the list:

Select your AlwaysUp service

After you save, Service Protector will babysit the AlwaysUp service — to quickly restart it if someone stops it:

Service Protector protecting the AlwaysUp service

Hopefully you will get to the bottom of this unwelcome behavior soon. Please be sure to get in touch if you notice any errors or warnings in the activity reports.

Posted in AlwaysUp | Tagged , , , , , | Leave a comment

Q&A: How do I tell that Dropbox is working as a Windows Service?

Q&A: How do I tell that Dropbox is working as a Windows Service?
  We’re trialing AlwaysUp to run Dropbox as a Windows Service without anyone logged on. But when I use AlwaysUp, I cannot see the Dropbox tray icon. How do I know that it’s working?

— Wendy

Hi Wendy.

Yes, verifying that Dropbox is functioning is more difficult when you can’t see and interact with it!

Here are the steps you should follow to prove that the popular file hosting software is working properly in the background as a Windows Service:

Test #1: Is Dropbox running?

First, make sure that the Dropbox.exe process is running. If Dropbox.exe isn’t active, it definitely won’t be able to copy your files!

To confirm that the process is running:

  1. Open the Windows Task Manager.

  2. If necessary, click More details to reveal additional information:

    Task Manager - More Details
  3. Switch to the Details tab and look for the Dropbox.exe process(es) in the list. We found a few on our system:

    Task Manager Details tab

If you don’t find any instances of the executable in Task Manager, it means that Dropbox isn’t running. Since you’re using AlwaysUp, check for errors — by selecting Report Activity from the Application menu — and see if you can figure out why the service is failing to start.

Note that when Dropbox is running properly, you should find 3 copies of the executable in Task Manager. That is completely normal — it’s just how the file synchronization software works.

Test #2: When you add a file online, is it copied down to your PC?

Now that you know that Dropbox is running, let’s check if it’s copying files from cloud storage to your local computer. Please follow these steps:

  1. Go to the Dropbox website and sign in to your account.

  2. Upload a new file to your account. A small text or PDF file should be fine.

    For example, here you can see that we have uploaded a file named “AlwaysUpWebServiceAPI.pdf”:

    New file uploaded to Dropbox Cloud
  3. Wait up to 5 minutes. It can take a while for Dropbox to recognize and copy the new file — especially if you have many files or folders in your account.

  4. On your PC, check for the file in the Dropbox folder. This is usually:

    C:\Users\<YOUR-USERNAME>\Dropbox

    As you can see here, our file was copied successfully:

    New file copied to the local folder

Did your file appear? If so, you are good!

If not, wait for a few more minutes. Perhaps Dropbox is copying other files and just hasn’t gotten to yours yet.

However, if you don’t see the new file on your PC after 10 minutes, it’s very likely that Dropbox isn’t functioning properly.

Test #3: When you create a file on your PC, is it copied up to the Dropbox cloud?

Whenever you create a new file, Dropbox should quickly copy it to your account online. Please perform these steps to make sure that’s happening:

  1. On your PC, open the local Dropbox folder in File Explorer. Once again, this is probably:

    C:\Users\<YOUR-USERNAME>\Dropbox

  2. Create a new text file in the folder. Give it a unique, recognizable name.

    For example, we called ours “Dropbox-test-03-21-2021.txt”:

    Create a new file in your Dropbox folder
  3. Wait a up to 5 minutes. It can take a while for Dropbox to recognize and copy the new file — especially if you have lots of files or folders in your account.

  4. Go to the Dropbox website and sign in to your account.

  5. Confirm that the file appears in your account.

    Once again, the test was successful on our system. The file appeared as expected:

    New file copied to the cloud

However, if you don’t see your file, please wait a bit longer. You can confidently declare a failure if the file doesn’t show up after 10 minutes.

Test #4: When you remove a file from your PC, is it removed online?

Local file deletions should be quickly reflected in the cloud. To check on that, please:

  1. Start File Explorer on your PC and navigate to your Dropbox folder.

  2. Delete a file that you don’t need — perhaps the one that you created in test #2.

    Note: If you see a confirmation window like this, be sure to check the Don’t ask me this again box before clicking the Delete everywhere button:

    Dropbox delete file confirmation

    If you don’t check that option, the pesky popup may resurface and stall file synchronization. You won’t be there to dismiss it when Dropbox is running invisibly in the background as an unattended service!

  3. Wait for up to 5 minutes. It can take a while for the file synchronization components to recognize the deletion and spring into action.

  4. Go online and confirm that the file has been removed from your cloud storage.

Test #5: When you delete a file from the Dropbox cloud, is it deleted from your PC?

Finally, whenever a file is deleted from your cloud storage, it should soon disappear from your PC’s shared folder. To verify that:

  1. Open your web browser and go to your cloud storage page.

  2. Find a file that you don’t need and delete it from the repository.

    For example, we chose to remove the file we created in test #3:

    Delete a file from cloud storage
  3. Wait up to 5 minutes for the deletion to propagate to your PC.

  4. Open File Explorer on your computer and confirm that the file has been removed from your local Dropbox folder.

If the file remains after 10 minutes, something is wrong.

Get in touch if any test failed

Did one or more of the tests fail? Please let us know and we’ll be happy to help.

In addition to the results of the 4 tests above, please be sure to send us the information outlined in this article so that we can provide our best support!

Posted in Dropbox | Tagged , , , | Leave a comment

Q&A: Why doesn’t Srvany Close my Application when I Stop the Service?

Q&A: Why doesn't Srvany close my Java application when I stop the service?
  We use Srvany to run our Java application as a service. It starts fine but when we stop the service our Java application does not close. We have to kill the java.exe process in Task Manager. That’s not supposed to happen, right? Is there a registry setting that we are missing that will shut down our application properly when we stop the service?

— Angela

Hi Angela.

As you probably know, Srvany is the original service wrapper. Its job is to accept commands from the Windows Service Control Manager (SCM) and take appropriate action on your java application. Simple, right?

Well, maybe not. Let’s examine what Microsoft’s service wrapper does when it receives the most important SCM commands — “start service” and “stop service”.

How Srvany handles the “Start Service” command

When you start your service — from the Services application, NET START, or SC START — the SCM immediately launches a fresh instance of srvany.exe and notifies it of the start request.

In response, Srvany:

  1. Informs the SCM that the service is starting.

  2. Starts the program configured to run as a service. The full command line is read from this registry value:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<Your Service>\Parameters\Application

If Srvany fails to start the application (which will happen if the application/path doesn’t exist), Srvany will:

  1. Inform the SCM that the service has stopped.

  2. Exit, ending the srvany.exe process.

On the other hand, if it successfully launches the application, Srvany will:

  1. Inform the SCM that the service is now running.

  2. Continue to run, listening for subsequent commands from the SCM.

Testing service start with Notepad

To confirm this behavior, we installed a new service (with Instsrv) and configured it to run the Windows Notepad text editor:

Notepad Windows Service installed with Srvany

We started the service.

With the help of Microsoft’s excellent Process Explorer, here is what the process tree looked like after a few seconds. As expected, there was a srvany.exe process that had spawned a notepad.exe child process:

Srvany running Notepad as a service

And Notepad was happily running in the background, on the isolated Session 0 desktop.

How Srvany handles the “Stop Service” command

When you attempt to stop your service — from the Services application, NET STOP, or SC STOP — the SCM immediately notifies the associated Srvany process of the stop request.

In response, Srvany will:

  1. Inform the SCM that the service is stopping.

  2. Close the process/application that it started.

  3. Inform the SCM that the service is stopped.

  4. Exit, ending the srvany.exe process.

When we stopped the Notepad service, Notepad.exe was terminated as expected.

But what happens when running a Java application/service?

Since stopping your Java application didn’t go smoothly, we decided to dig into that specific scenario.

We installed a new service and configured it to launch a Java JAR package:

Java/JAR Windows Service installed

When we started the service, we saw srvany.exe launch java.exe. No surprises there:

Srvany running Java as a service

And when we stopped the service, the java.exe process ended and Srvany exited — all good.

So how come it isn’t working for you?

What about a Java application started from a batch file?

After some head scratching, we realized something important. Many of our customers running Java as a service with AlwaysUp don’t run java directly. Instead, they start java via a batch file because it gives them the opportunity to set important environment variables in advance. Could that be an issue?

To answer that question, we created a simple batch file that launched java and installed a new service to run the batch file:

Batch File Windows Service installed

We started the service. Srvany launched the batch file (cmd.exe), which in turn launched Java — all as intended:

Srvany running the batch file (and Java) as a service

However, when tried to stop the service, something unexpected happened. The service stopped and srvany.exe and cmd.exe closed, but java.exe did not exit! The Java process remained running, even after the service had transitioned to the stopped state. It was exactly as you described.

So from these tests, it seems that Srvany will terminate the process it launched (i.e. its direct child process) but will not terminate any descendant processes.

Do you think this is what you are experiencing? If so, please read on for a couple of potential solutions.

Solution #1: Run the Java executable directly from Srvany

Instead of starting Java from a batch file, let Srvany run your Java.exe command line itself. As we have shown above, Srvany is able to terminate Java when it launches it directly.

However, this option may be impractical if your batch file performs lots of setup. But if the batch file focuses on setting environment variables (e.g. CLASSPATH), you can get around that by:

  1. Permanently setting the environment variables in a specific user account, and

  2. Running Java in that account (by specifying the user’s details on the service’s Log On tab).

Solution #2: Install your Java application as a service with AlwaysUp instead of Srvany

Alternatively, if this is a professional setting and a commercial option is acceptable, you can replace Srvany with our AlwaysUp utility.

When you stop a service created by AlwaysUp, all descendant processes are terminated. That is, AlwaysUp will close cmd.exe, java.exe — and any other processes that your Java application spawns. You will never have a situation where your service is stopped but some processes remain alive.

Please review the benefits to using AlwaysUp instead of Srvany to see if you should make the switch.

Best of luck managing your Java application!

Posted in Srvany | Tagged , , , , , | Leave a comment

Service Protector 7.0: Informative Email Alerts, Sanity Check Options and More

What's new in Service Protector 7.0

Are you responsible for a temperamental Windows Service? If so, you should definitely check out the latest version of Service Protector — the easiest way to achieve 100% uptime today.

Here’s what’s new in this release:

Email alerts include recent activity

Customers who have configured email alerts will notice that messages now contain the service’s last five events from the Windows Event Logs. The idea is to provide helpful context when something unusual happens, to avoid you having to log on to interrogate Service Protector’s reports.

Here is what an email with the new Recent Activity section looks like:

Service Protector email alerts include recent activity

Delay the initial Sanity Check when detecting service problems

A customized sanity check is an excellent way to extend failure detection and automatically restart a faltering service. With a sanity check, you can probe network connectivity, check for a “stale” output file, and much more — whatever you like!

Service Protector version 7 allows you to delay the first sanity check. This is useful when your service takes a while to get ready — either at boot or after it has been restarted.

The new delay settings appear on the Configure Sanity Check window:

Service Protector: Configure Sanity Check

Full compatibility with Windows 10 20H2

Microsoft published Windows 10, version 20H2 in October 2020.

From the release notes, 20H2 doesn’t include significant changes to the Windows Services infrastructure. The update focused mostly on end-user improvements for the Edge browser, task tray notifications and the like.

Nevertheless, our team tested Service Protector 7.0 extensively on the new version of Windows 10. We’re pleased to report that no problems were detected and Service Protector remains fully compatible with all versions of Windows 10.

Service Protector is compatible with Windows 10 20H2

As usual, please review the release notes for the full list of features, fixes and improvements included in this release.

Upgrading to Service Protector 7

If you purchased Service Protector version 6 (after February 2019) you can upgrade to version 7 for free. Simply download and install “over the top” to preserve your existing services and all settings. Your registration code will continue to work.

If you bought version 5 or earlier (before February 2019), you will need to upgrade to use version 7. Please purchase upgrades here — at a 50% discount.

See the full upgrade policy for additional details.

Enjoy!

Posted in Service Protector | Tagged , , , , | Leave a comment

Q&A: Does AlwaysUp work in High Availability Failover Clusters?

Does AlwaysUp work with High Availability Failover Clustering?
My team inherited a cluster of 4 Windows Server 2012 R2 machines running a legacy finance application. At a time only one instance of the application should be up and running as the active/primary instance.

The application is cluster-unaware so we set it up with the Generic Application type. Most days it works fine but about once or twice per month the EXE stops responding and no failover happens. Someone has to log in and kill it to trigger failover, which is just plain silly.

I see that your AlwaysUp may be able to better manage the program. My question is, can your product work to control and maintain the supervision of these instances?

— Andrei

Hi Andrei.

Several of our corporate customers have deployed AlwaysUp in Windows clusters. They tell us that, despite having no specific features that target cluster management, AlwaysUp works very well in that context.

In situations like yours where 100% uptime of a particular application is important, AlwaysUp adds an efficient line of defense — one that complements traditional multi-machine failover. Here’s how that works.

Application resilience: AlwaysUp protects against application failures

AlwaysUp’s job is to ensure that your application is always running. If your application crashes, AlwaysUp will automatically restart it.

But AlwaysUp provides much more than basic crash protection. It can operate proactively, rooting out problematic situations before they metastasize into full blown failures.

For example, you can have AlwaysUp quickly recycle your application if it:

  • Monopolizes the CPU for too long;

  • Consumes too much RAM;

  • Fails to respond properly to network/web requests;

  • Stops writing to a log file.

In it helps, you can even have AlwaysUp restart your finance program once a week during off-hours — to fend off mysterious lock-ups and other unpleasant instabilities.

Less downtime when your application fails

Most importantly, your system/service will likely experience less downtime when AlwaysUp is the first line of defense. Instead of waiting for the cluster failure to be detected and the switchover to the backup server to occur, your application will quickly bounce back on the active server. That rapid resolution can shave many precious seconds off your recovery time!

System resilience: Clustering protects against catastrophic failures

While AlwaysUp is able to cure many application failures, there are a range of deeper problems that it cannot solve. For example, when:

  • The machine loses power;

  • The server’s operating system crashes;

  • The network experiences an outage;

  • A critical hardware component (motherboard, hard drive, etc.) malfunctions.

For those dicey situations — where a server has been compromised — your failover cluster setup will save the day.

Configure a “Generic Service” instead of a “Generic Application”

Since you set up a Generic Application resource type to monitor your important program, you should remove that and replace it with a Generic Service that monitors the Windows Service created by AlwaysUp:

Select Generic Service in the High Availability Wizard

That change will enable your cluster to fail over whenever AlwaysUp protection stops — not when your legacy application fails. That is an important distinction.

If your application is named “Legacy Finance App” in AlwaysUp, select the Windows Service called “Legacy Finance App (managed by AlwaysUpService)”. You can find out more about the service created by AlwaysUp on the Frequently Asked Questions (FAQ) page.

Best of luck with your legacy application!

Posted in AlwaysUp | Tagged , , , , , | Leave a comment